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