/// <summary> /// Logs an error message /// </summary> /// <param name="exception">The exception.</param> /// <param name="format">The format.</param> /// <param name="args">The args.</param> protected void Error(Exception exception, string format, params object[] args) { SystemStringFormat message = new SystemStringFormat(CultureInfo.InvariantCulture, format, args); string errorMessage; if (exception != null) errorMessage = string.Format("{0}: {1}", message, exception.Message); else errorMessage = message.ToString(); errors.Add(new FdoETLException(errorMessage, exception)); OnError(this, new MessageEventArgs(message.ToString())); }
public void StringFormat() { var layout = new GelfLayout(); var message = new SystemStringFormat(CultureInfo.CurrentCulture, "This is a {0}", "test"); var loggingEvent = GetLogginEvent(message); var result = GetMessage(layout, loggingEvent); Assert.AreEqual(message.ToString(), result.FullMessage); Assert.AreEqual(message.ToString(), result.ShortMessage); }
/// <summary> /// Logs a warn message /// </summary> /// <param name="format">The format.</param> /// <param name="args">The args.</param> protected void Warn(string format, params object[] args) { var ssf = new SystemStringFormat(CultureInfo.InvariantCulture, format, args); if (log.IsWarnEnabled) { log.Logger.Log(GetType(), Level.Warn, ssf, null); } OnWarn(this, new MessageEventArgs(ssf.ToString())); }
/// <summary> /// Logs an error message /// </summary> /// <param name="exception">The exception.</param> /// <param name="format">The format.</param> /// <param name="args">The args.</param> protected void Error(Exception exception, string format, params object[] args) { SystemStringFormat message = new SystemStringFormat(CultureInfo.InvariantCulture, format, args); string errorMessage; if(exception!=null) errorMessage = string.Format("{0}: {1}", message, exception.Message); else errorMessage = message.ToString(); errors.Add(new RhinoEtlException(errorMessage, exception)); if (log.IsErrorEnabled) { log.Logger.Log(GetType(), Level.Error, message, exception); } }
/// <summary> /// Logs a notice message /// </summary> /// <param name="format">The format.</param> /// <param name="args">The args.</param> protected void Notice(string format, params object[] args) { var ssf = new SystemStringFormat(CultureInfo.InvariantCulture, format, args); if (log.Logger.IsEnabledFor(Level.Notice)) { log.Logger.Log(GetType(), Level.Notice, ssf, null); } OnNotice(this, new MessageEventArgs(ssf.ToString())); }