Beispiel #1
0
        public void StringFormat_WithRenderedMessage()
        {
            var layout = new GelfLayout();

            var message      = new SystemStringFormat(CultureInfo.CurrentCulture, "This is a {0}", "test");
            var loggingEvent = GetLogginEventRenderedMessage(message.ToString());

            var result = GetMessage(layout, loggingEvent);

            Assert.AreEqual(message.ToString(), result.FullMessage);
            Assert.AreEqual(message.ToString(), result.ShortMessage);
        }
Beispiel #2
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()));
        }
Beispiel #3
0
        /// <summary>
        /// Logs a debug message
        /// </summary>
        /// <param name="format">The format.</param>
        /// <param name="args">The args.</param>
        protected void Debug(string format, params object[] args)
        {
            var ssf = new SystemStringFormat(CultureInfo.InvariantCulture, format, args);

            if (log.IsDebugEnabled)
            {
                log.Logger.Log(GetType(), Level.Debug, ssf, null);
            }
            OnDebug(this, new MessageEventArgs(ssf.ToString()));
        }
Beispiel #4
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()));
        }
        public void StringFormat()
        {
            var layout = new LogMessageLayout();

            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.Message);
        }
Beispiel #6
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);
            }
        }