📄 logbuffer.cs
字号:
/*
Copyright 2006 Christian Gross http://www.devspace.com
From the book Ajax Patterns and Best Practices
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
using Devspace.Ajax.PersistentCommunications;
using System.Web;
using System.IO;
namespace Devspace.Ajax.Logging {
public class LogBuffer : HttpHandlerBase {
private string _baseURL;
public LogBuffer() {
_baseURL = "/logging/message";
}
/// <summary>
/// Method DoGet
/// </summary>
/// <param name="req">A HttpRequest</param>
/// <param name="resp">A HttpResponse</param>
protected internal override void DoGet(HttpRequest req, HttpResponse resp) {
// TODO: Implement this method
}
/// <summary>
/// Method DoPost
/// </summary>
/// <param name="req">A HttpRequest</param>
/// <param name="resp">A HttpResponse</param>
protected internal override void DoPost(HttpRequest request, HttpResponse response) {
string requestURL = request.Path;
if( requestURL.Length < (_baseURL.Length + 1)) {
response.Status = "Bad URL";
response.StatusCode = 500;
return;
}
Stream inpStream = request.InputStream;
byte[] toReadBuffer = new byte[inpStream.Length];
if (inpStream.Read(toReadBuffer, 0, toReadBuffer.Length) > 0) {
string message = System.Text.Encoding.ASCII.GetString( toReadBuffer);
string identifier = requestURL.Substring( _baseURL.Length + 1);
if( identifier.CompareTo( "fatal") == 0) {
Devspace.Commons.Logging.Fatal( message + "\n");
}
else if( identifier.CompareTo( "error") == 0) {
Devspace.Commons.Logging.Error( message + "\n");
}
else if( identifier.CompareTo( "warning") == 0) {
Devspace.Commons.Logging.Warn( message + "\n");
}
else if( identifier.CompareTo( "info") == 0) {
Devspace.Commons.Logging.Info( message + "\n");
}
else if( identifier.CompareTo( "debug") == 0) {
Devspace.Commons.Logging.Debug( message + "\n");
}
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -