예제 #1
0
        public static LumberjackMessageBuilder Measure(this LumberjackMessageBuilder builder, string name, double value)
        {
            var ts = (long)(DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0)).TotalSeconds;

            builder.MetricMessage = new LumberjackMetricMessage(builder.Source, builder.AppId, builder.Component, name, value, ts);
            return(builder);
        }
예제 #2
0
 public static LumberjackMessageBuilder Log(this LumberjackMessageBuilder builder, LogLevel logLevel, string message)
 {
     builder.LogMessage = new LumberjackMessage(builder.Source, builder.AppId, builder.Component, logLevel, message)
     {
         Tags = new HashSet <string>()
     };
     return(builder);
 }
예제 #3
0
 public static LumberjackMessageBuilder WithTags(this LumberjackMessageBuilder builder, params Guid[] tags)
 {
     if (builder.LogMessage == null)
     {
         throw new ArgumentException("Message not set");
     }
     builder.LogMessage.Tags.UnionWith(tags.Select(i => i.ToString("N")));
     return(builder);
 }
예제 #4
0
        public static void Commit(this LumberjackMessageBuilder builder)
        {
            if (builder.LogMessage != null)
            {
                builder.Logger.Log(builder.LogMessage);
            }

            if (builder.AlertMessage != null)
            {
                builder.Logger.Alert(builder.AlertMessage);
            }

            if (builder.MetricMessage != null)
            {
                builder.Logger.Measure(builder.MetricMessage);
            }
        }
예제 #5
0
 public static LumberjackMessageBuilder WithField(this LumberjackMessageBuilder builder, string name, object value)
 {
     if (builder.LogMessage == null)
     {
         throw new ArgumentException("Message not set");
     }
     if (builder.LogMessage.Fields == null)
     {
         builder.LogMessage.Fields = new Dictionary <string, object> {
             { name, value }
         };
     }
     else
     {
         builder.LogMessage.Fields[name] = value;
     }
     return(builder);
 }
예제 #6
0
 public static LumberjackMessageBuilder WithFields(this LumberjackMessageBuilder builder, IDictionary <string, object> fields)
 {
     if (builder.LogMessage == null)
     {
         throw new ArgumentException("Message not set");
     }
     if (builder.LogMessage.Fields == null)
     {
         builder.LogMessage.Fields = new Dictionary <string, object>(fields);
     }
     else
     {
         foreach (var kvp in fields)
         {
             builder.LogMessage.Fields[kvp.Key] = kvp.Value;
         }
     }
     return(builder);
 }
예제 #7
0
 public static LumberjackMessageBuilder Fatal(this LumberjackMessageBuilder builder, string message)
 {
     return(builder.Log(LogLevel.Fatal, message));
 }
예제 #8
0
 public static LumberjackMessageBuilder Error(this LumberjackMessageBuilder builder, string message)
 {
     return(builder.Log(LogLevel.Error, message));
 }
예제 #9
0
 public static LumberjackMessageBuilder Info(this LumberjackMessageBuilder builder, string message)
 {
     return(builder.Log(LogLevel.Info, message));
 }
예제 #10
0
 public static LumberjackMessageBuilder Debug(this LumberjackMessageBuilder builder, string message)
 {
     return(builder.Log(LogLevel.Debug, message));
 }
예제 #11
0
 public static LumberjackMessageBuilder Trace(this LumberjackMessageBuilder builder, string message)
 {
     return(builder.Log(LogLevel.Trace, message));
 }
예제 #12
0
 public static LumberjackMessageBuilder Measure(this LumberjackMessageBuilder builder, string name, double value, long timestamp)
 {
     builder.MetricMessage = new LumberjackMetricMessage(builder.Source, builder.AppId, builder.Component, name, value, timestamp);
     return(builder);
 }
예제 #13
0
 public static LumberjackMessageBuilder Alert(this LumberjackMessageBuilder builder, string name, string message)
 {
     builder.AlertMessage = new LumberjackAlertMessage(builder.Source, builder.AppId, builder.Component, name, message);
     return(builder);
 }