Ejemplo n.º 1
0
        /// <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()));
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
 /// <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()));
 }
Ejemplo n.º 4
0
 /// <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);
     }
 }
Ejemplo n.º 5
0
 /// <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()));
 }