public void Add(HttpRequest httpRequest, HttpResponse httpResponse, object objRequest = null, object objResponse = null) { lock (View) { ++Count; JsonType jsonType = JsonType.Handshake; JsonAction jsonAction = JsonAction.Request; LogDevice device = LogDevice.Client; if (objRequest != null && objRequest is JsonPacket) { JsonPacket jsonRequest = (JsonPacket)objRequest; JsonMessage jsonMessage = JsonMessage.Parse(jsonRequest.Message); jsonAction = jsonMessage.Action; jsonType = jsonMessage.Type; if (!httpRequest.HasSession()) { device = LogDevice.Server; } } StringBuilder sb = new StringBuilder(); sb.Append("[ ").Append(device.ToString().ToUpper()).Append(" ]").Append(Constant.Newline); sb.Append("[ ").Append(jsonType.ToString().ToUpper()).Append(" ").Append(jsonAction.ToString().ToUpper()).Append(" ]"); Add(sb); Add(httpRequest, objRequest, Suffix.EOM); Add(httpResponse, objResponse, Suffix.EOL); } }
public Logger(LogDevice logDevice, string appBasePath) { LogDevice = logDevice; LOGBasePath = string.Format("{0}\\LOG", appBasePath); if (!Directory.Exists(LOGBasePath)) { Directory.CreateDirectory(LOGBasePath); } }
public static void Info(string sContext, string sMsg, LogDevice devLog) { /// 1.0.9.14 // Info with Ellapsed Time instead of Date Time string sMsg1 = "Info - " + DateTime.Now.ToString(Cfg.Date_FormatString + " " + HMSF).ToString() + " [" + Session_Nbr.ToString() + "], " + sMsg; if ((devLog & LogDevice.LOG) == LogDevice.LOG) { AppendLog(sMsg1); } if ((devLog & LogDevice.CON) == LogDevice.CON) { Console.WriteLine(sMsg1); } if ((devLog & LogDevice.DLG) == LogDevice.DLG) { MessageBox.Show(sMsg1, "Info", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
public static void Err(Exception ex, string sContext, string sMsg, LogDevice devLog) { /// 1.0.9.14 string sMsg1 = "Err - " + DateTime.Now.ToString(Cfg.Date_FormatString + " " + HMSF).ToString() + "[" + Session_Nbr.ToString() + "], " + sContext + ": " + sMsg + CRLF + ex.Source + ":" + CRLF + ex.Message; if (ex.InnerException != null) { sMsg1 += sMsg1 + CRLF + ex.InnerException.Message; } if ((devLog & LogDevice.LOG) == LogDevice.LOG) { AppendLog(sMsg1); } if ((devLog & LogDevice.CON) == LogDevice.CON) { Console.WriteLine(sMsg1); } if ((devLog & LogDevice.DLG) == LogDevice.DLG) { MessageBox.Show(sMsg1, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <summary> /// Constructor /// </summary> public Logger(LogDevice console) : this(LogDevice.Console, string.Empty) { }
/// <summary> /// Registers a LogDevice /// A registered LogDevice will be called each time a new LogItem is received /// (see Write method) /// </summary> /// <param name="aLogger">Device to register</param> public void Register(LogDevice aLogger) { logDevices.Add(aLogger); }