Esempio n. 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);
        }
Esempio n. 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);
 }
Esempio n. 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);
 }
Esempio n. 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);
            }
        }
Esempio n. 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);
 }
Esempio n. 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);
 }
Esempio n. 7
0
 public static LumberjackMessageBuilder Fatal(this LumberjackMessageBuilder builder, string message)
 {
     return(builder.Log(LogLevel.Fatal, message));
 }
Esempio n. 8
0
 public static LumberjackMessageBuilder Error(this LumberjackMessageBuilder builder, string message)
 {
     return(builder.Log(LogLevel.Error, message));
 }
Esempio n. 9
0
 public static LumberjackMessageBuilder Info(this LumberjackMessageBuilder builder, string message)
 {
     return(builder.Log(LogLevel.Info, message));
 }
Esempio n. 10
0
 public static LumberjackMessageBuilder Debug(this LumberjackMessageBuilder builder, string message)
 {
     return(builder.Log(LogLevel.Debug, message));
 }
Esempio n. 11
0
 public static LumberjackMessageBuilder Trace(this LumberjackMessageBuilder builder, string message)
 {
     return(builder.Log(LogLevel.Trace, message));
 }
Esempio n. 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);
 }
Esempio n. 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);
 }