?? impslogger.cs
字號:
writer.WriteString(summary);
writer.WriteEndElement();
writer.WriteStartElement("Detail");
if (detail.IndexOfAny("<>".ToCharArray()) >= 0)
{
writer.WriteCData(detail.Replace("]]>", "?]>"));
}
else
{
writer.WriteString(detail);
}
writer.WriteEndElement();
writer.WriteStartElement("CallStack");
writer.WriteCData(this.IsNeedCallStack(category, infoLevel) ? this.GetCallStack() : string.Empty);
writer.WriteEndElement();
writer.WriteStartElement("ExtData");
if (!string.IsNullOrEmpty(ext))
{
System.Text.RegularExpressions.Match match = this._ExtRegex.Match(ext);
if (match.Success)
{
foreach (System.Text.RegularExpressions.Match match2 in Regex.Matches(match.Groups[1].Value, @"(\S+?)\s*=\s*(\S+)", RegexOptions.Multiline))
{
writer.WriteAttributeString(match2.Groups[1].Value, this.TrimValue(match2.Groups[2].Value));
}
writer.WriteCData(match.Groups[2].Value);
}
else
{
writer.WriteCData(ext);
}
}
writer.WriteEndElement();
writer.WriteEndElement();
writer.Flush();
byte[] bytes = Encoding.UTF8.GetBytes("\r\n");
w.Write(bytes, 0, bytes.Length);
}
lock (this._LogFile)
{
string contents = Encoding.UTF8.GetString(w.ToArray());
if ((this.LogType | Imps.Client.Utils.LogType.GlobalFile) != Imps.Client.Utils.LogType.None)
{
System.IO.File.AppendAllText(this._LogFile, contents, Encoding.UTF8);
}
if ((this.LogType | Imps.Client.Utils.LogType.SingleFile) != Imps.Client.Utils.LogType.None)
{
System.IO.File.AppendAllText(this.GetLogFileNameByCategory(category), contents, Encoding.UTF8);
}
}
}
}
catch
{
}
}
}
private static string CurrentProcessId
{
get
{
if (string.IsNullOrEmpty(_processId))
{
_processId = Process.GetCurrentProcess().Id.ToString();
}
return _processId;
}
}
public bool IsLogBiz
{
get
{
return this._IsLogBiz;
}
set
{
this._IsLogBiz = value;
}
}
public bool IsLogConnection
{
get
{
return this._IsLogConnection;
}
set
{
this._IsLogConnection = value;
}
}
public bool IsLogException
{
get
{
return this._IsLogException;
}
set
{
this._IsLogException = value;
}
}
public bool IsLogGeneral
{
get
{
return this._IsLogGeneral;
}
set
{
this._IsLogGeneral = value;
}
}
public bool IsLogInstall
{
get
{
return this._IsLogInstall;
}
set
{
this._IsLogInstall = value;
}
}
public bool IsLogLiveUpdate
{
get
{
return this._IsLogLiveUpdate;
}
set
{
this._IsLogLiveUpdate = value;
}
}
public bool IsLogLogin
{
get
{
return this._IsLogLogin;
}
set
{
this._IsLogLogin = value;
}
}
public bool IsLogSipc
{
get
{
return this._IsLogSipc;
}
set
{
this._IsLogSipc = value;
}
}
public string LogFolder
{
get
{
return this._LogFolder;
}
set
{
this._LogFolder = value;
}
}
public Imps.Client.Logger.LogHeader LogHeader
{
get
{
return this._LogHeader;
}
}
public Imps.Client.Utils.LogType LogType
{
get
{
return this._LogType;
}
set
{
this._LogType = value;
}
}
public int MaxLogNo
{
get
{
return this._MaxLogNo;
}
set
{
if ((value <= 0) || (value > 100))
{
throw new ArgumentException("最大文件號必須在1-100范圍之內");
}
this._MaxLogNo = value;
}
}
public string ServerUrl
{
get
{
return this._ServerUrl;
}
set
{
this._ServerUrl = value;
}
}
public int ThresholdLevel
{
get
{
return this._ThresholdLevel;
}
set
{
this._ThresholdLevel = value;
}
}
private class ImpsLoggerSender
{
private string _ServerUrl;
private CookieContainer cookie = new CookieContainer();
public ImpsLoggerSender(string serverUrl)
{
this._ServerUrl = serverUrl;
}
public void Post(byte[] buffer)
{
this.Post(buffer, 0, buffer.Length);
}
public void Post(byte[] buffer, int start, int length)
{
HttpWebRequest request = ConnectionFactory.CreateHttpWebRequest(this._ServerUrl, null, true, true);
if (length != 0)
{
GZipStream stream = new GZipStream(request.GetRequestStream(), CompressionMode.Compress, false);
stream.Write(buffer, start, length);
stream.Close();
}
((HttpWebResponse) request.GetResponse()).Close();
}
public void PostEnd()
{
this.Post(new byte[0]);
}
}
[StructLayout(LayoutKind.Sequential)]
private struct MEMORY_INFO
{
public uint dwLength;
public uint dwMemoryLoad;
public uint dwTotalPhys;
public uint dwAvailPhys;
public uint dwTotalPageFile;
public uint dwAvailPageFile;
public uint dwTotalVirtual;
public uint dwAvailVirtual;
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -