Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
 /// <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);
     }
 }
Exemplo n.º 3
0
 /// <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);
     }
 }
Exemplo n.º 4
0
        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);
        }
Exemplo n.º 5
0
    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);
    }
Exemplo n.º 6
0
        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);
        }