Пример #1
0
 /// <summary>
 /// Is given log level logging enabled.
 /// </summary>
 /// <param name="logLevel">Log Level</param>
 /// <returns>true if Log Level is enabled, otherwise false.</returns>
 public bool IsLogLevelEnabled(LogLevels logLevel)
 {
     if (RealLogger == null)
     {
         return(false);
     }
     return(RealLogger.IsLogLevelEnabled(logLevel));
 }
Пример #2
0
        /// <summary>
        /// Log a formatable text and optional messageArgs.
        /// </summary>
        /// <param name="logLevel">Log Level</param>
        /// <param name="messageFormat">Text message containing formatting section.</param>
        /// <param name="messageArgs">Arguments to be rendered/formatted part of the Text message.</param>
        /// <returns>Actual formatted text that got logged.</returns>
        public string Log(LogLevels logLevel, string messageFormat, params object[] messageArgs)
        {
            //** prevent to do anything if not logging for the target log level...
            if (!IsLogLevelEnabled(logLevel))
            {
                return(string.Empty);
            }

            var msg = format(messageFormat, messageArgs);

            if (msg == null)
            {
                throw new ArgumentNullException("messageFormat",
                                                "Log failed as there is no data to write, params are null.");
            }
#if (DEBUG)
            var str = RealLogger.Log(logLevel, messageFormat, messageArgs);
            Console.WriteLine(str);
            return(str);
#else
            return(RealLogger.Log(logLevel, messageFormat, messageArgs));
#endif
        }
Пример #3
0
        /// <summary>
        /// Log exception on given log level with add'l formatable text msg and optional messageArgs.
        /// </summary>
        /// <param name="logLevel">Log Level</param>
        /// <param name="exc">exception to be logged.</param>
        /// <param name="messageFormat">Text message containing formatting section.</param>
        /// <param name="messageArgs">Arguments to be rendered/formatted part of the Text message.</param>
        /// <returns>Actual formatted text that got logged.</returns>
        public string Log(LogLevels logLevel, Exception exc, string messageFormat, params object[] messageArgs)
        {
            if (!IsLogLevelEnabled(logLevel))
            {
                return(string.Empty);
            }

            var msg = format(exc, messageFormat, messageArgs);

            if (msg == null)
            {
                throw new ArgumentNullException("messageFormat",
                                                "Log failed as there is no data to write, params are null.");
            }

#if (DEBUG)
            var str = RealLogger.Log(logLevel, exc, messageFormat, messageArgs);
            Console.WriteLine(str);
            return(str);
#else
            return(RealLogger.Log(logLevel, exc, messageFormat, messageArgs));
#endif
        }
Пример #4
0
 /// <summary>
 /// Is given log level logging enabled.
 /// </summary>
 /// <param name="logLevel">Log Level</param>
 /// <returns>true if Log Level is enabled, otherwise false.</returns>
 public bool IsLogLevelEnabled(LogLevels logLevel)
 {
     return(RealLogger.IsLogLevelEnabled(logLevel));
 }