public void Message(object sender, LogEvent.Severity severity, string msg) { if (OnMessage != null) { OnMessage(sender, new LogEvent(severity, msg)); } }
private string FormatMsg(LogEvent.Severity severity, string msg, params object[] args) { if (Format != null) { var stackTrace = new StackTrace(); msg = _formatRegEx.Replace(Format, m => { switch (m.Groups[1].Value) { case "%": return("%"); case "s": return(severity.ToString().ToLower()); case "S": return(severity.ToString().ToUpper()); case "m": return(msg); case "c": var frame = stackTrace.GetFrame(2); var method = frame.GetMethod(); var type = method.ReflectedType; return(type.Namespace + "." + type.Name + "." + method.Name); // + ":" + frame.GetFileLineNumber(); } return(m.Value); }); } return(String.Format(msg, args)); }
public static void OnLogEventOccurred(string message, LogEvent.Severity severity) { EventHandler <EventArgs <LogEvent> > handler = LogEvent; if (handler != null) { handler( null, new EventArgs <LogEvent>( new LogEvent() { LogSeverity = severity, Message = message, Timestamp = DateTime.Now, })); } }