コード例 #1
0
 public Task Log(object message, SimpleLogLevel level)
 {
     if (this.ShouldLog(level))
     {
         var args = LogMessageArgs.Create(Category, message, level);
         LogActions.Invoke(args);
     }
     return(Task.CompletedTask);
 }
コード例 #2
0
        public void Invoke(LogMessageArgs args)
        {
            //todo result cache?
            var logMessageActions = this.Values.Where(x => x.Enabled).ToList();

            foreach (var logMessageAction in logMessageActions)
            {
                logMessageAction.Action(args);
            }
        }
コード例 #3
0
 private static void LogMessage(LogMessageArgs args)
 {
     if (_prefix == null)
     {
         _prefix = string.IsNullOrWhiteSpace(SimpleLogSettings.DefaultPrefix)
             ? string.Empty
             : string.Format("[{0}]", SimpleLogSettings.DefaultPrefix.Trim());
     }
     Trace.WriteLine(string.Format("{0} [{1}][{2}]{3} {4}", args.Category, "SimpleLog", args.Level.ToString(), _prefix, args.Message));
 }