/// <summary> /// C#-oriented-method: Write a log line to the logger. Exposes all parameters in a way that should make /// it very easy to use the logging behaviour from C#. /// </summary> /// <remarks> /// This method takes the **LogLevel** first, and then the message; to avoid having to grapple with /// overload resolution. The other Log(string, LogLine ...) method is in F# and won't add the same /// good defaults as this method. /// </remarks> /// <param name="logger"></param> /// <param name="level"></param> /// <param name="message">This is the message that you want to log. /// It's worth noting that a message without string.Format-ed parameters, is more equal /// across time, and if you have custom data you want to pass, you should rather set /// that data on the 'data' property of LogLine (with SetData and SetDatas).</param> /// <param name="setterTransformer"> /// There are extension methods in this library that go towards creating new instances /// of LogLine that you can use to change the value inside this function. /// </param> public static void Log( this Logger logger, LogLevel level, string message, Func <LogLine, LogLine> setterTransformer) { if (logger == null) { throw new ArgumentNullException("logger"); } if (level == null) { throw new ArgumentNullException("level"); } if (message == null) { throw new ArgumentNullException("message"); } if (setterTransformer == null) { throw new ArgumentNullException("setterTransformer"); } var line = LogLineModule.Create(level, message); logger.Log(setterTransformer(line)); }
/// <summary> /// Set the LogLine's timestamp /// </summary> public static LogLine SetTimestamp(this LogLine line, Instant timestamp) { return(LogLineModule.SetTimestamp(timestamp, line)); }
/// <summary> /// Add the key-value pairs to the data /// </summary> public static LogLine SetDatas(this LogLine line, IEnumerable <KeyValuePair <string, object> > values) { return(LogLineModule.SetDatas(values.Select(kv => Tuple.Create(kv.Key, kv.Value)), line)); }
/// <summary> /// Add a key-value pair to the data /// </summary> public static LogLine SetData(this LogLine line, string key, object data) { return(LogLineModule.SetData(key, data, line)); }
/// <summary> /// Add a tag 'tag' to the log line 'line'. /// </summary> public static LogLine SetTag(this LogLine line, string tag) { return(LogLineModule.SetTag(tag, line)); }
/// <summary> /// Sets the path of the log line /// </summary> public static LogLine SetPath(this LogLine line, string path) { return(LogLineModule.SetPath(path, line)); }
/// <summary> /// Sets the level of the log line /// </summary> public static LogLine SetLevel(this LogLine line, LogLevel level) { return(LogLineModule.SetLevel(level, line)); }
/// <summary> /// Set the LogLine's main exception property /// </summary> public static LogLine SetExn(this LogLine line, Exception ex) { return(LogLineModule.SetExn(ex, line)); }
/// <summary> /// Sets the message of the log line /// </summary> public static LogLine SetMessage(this LogLine line, string message) { return(LogLineModule.SetMsg(message, line)); }