private string GetFormattedLocation(IStackTrace location) { if (!HBS.Logging.Logger.IsStackTraceEnabled || location == null || location.FrameCount < 1) { return(null); } var stackTrace = Traverse.Create((DiagnosticsStackTrace)location)?.Field <StackTrace>("stackTrace")?.Value; if (stackTrace == null || stackTrace.FrameCount < 1) { return(null); } var method = stackTrace.GetFrame(0).GetMethod(); var formatted = string.Format(settings.LocationFormat, method.DeclaringType, method.Name); return(formatted); }
/// <summary> /// /// </summary> /// <param name="acDomain"></param> /// <param name="acts"></param> /// <param name="actor"></param> /// <param name="name"></param> public WfAct(IAcDomain acDomain, IStackTrace acts, IWfResource actor, string name) { if (actor == null) { throw new ArgumentNullException("actor"); } if (acDomain == null) { throw new ArgumentNullException("acDomain"); } this._acDomain = acDomain; if (acDomain.Config.TraceIsEnabled) { this.ActorId = actor.Id; this.ActorName = actor.Name; this.ActorType = actor.BuiltInResourceKind.ToName(); this.ActingOn = DateTime.Now; this.Name = name; acts.Trace(this); } }
/// <summary> /// /// </summary> /// <param name="acDomain"></param> /// <param name="acts"></param> /// <param name="actor"></param> /// <param name="name"></param> public WfAct(IAcDomain acDomain, IStackTrace acts, IWfResource actor, string name) { if (actor == null) { throw new ArgumentNullException("actor"); } if (acDomain == null) { throw new ArgumentNullException("acDomain"); } this._acDomain = acDomain; if (acDomain.Config.TraceIsEnabled) { this.ActorId = actor.Id; this.ActorName = actor.Name; this.ActorType = actor.BuiltInResourceKind.ToName(); this.ActingOn = DateTime.Now; this.Name = name; acts.Trace(this); } }
internal string GetFormattedLogLine(string name, LogLevel logLevel, object message, Object context, Exception exception, IStackTrace location) { var line = string.Format(settings.LogLineFormat, GetFormattedTime(), GetFormattedLogLevel(logLevel), GetFormattedName(name), GetFormattedMessage(message), exception == null ? GetFormattedLocation(location) : GetFormattedException(exception) ); if (settings.NormalizeNewLines) { line = NEWLINE_REGEX.Replace(line, Environment.NewLine); } if (settings.IndentNewLines) { line = NEWLINE_REGEX.Replace(line, Environment.NewLine + "\t"); } return(line); }
public void OnLogMessage(string logName, LogLevel level, object message, Object context, Exception exception, IStackTrace location) { var formatted = BetterLogFormatter.GetFormattedLogLine(level, message, exception); writer.WriteLine(formatted); }
public virtual void OnLogMessage(string logName, LogLevel level, object message, Object context, Exception exception, IStackTrace location) { var formatted = formatter.GetFormattedLogLine(logName, level, message, context, exception, location); streamWriter.WriteLine(formatted); }