Esempio n. 1
0
 /// <summary>
 /// Log current log levels
 /// </summary>
 public static void WriteLogLevels(IPBan.LogLevel level = LogLevel.Warn)
 {
     if (logger != null)
     {
         IPBanLog.Write(level, "Log levels: {0},{1},{2},{3},{4},{5}", logger.IsFatalEnabled, logger.IsErrorEnabled, logger.IsWarnEnabled, logger.IsInfoEnabled, logger.IsDebugEnabled, logger.IsTraceEnabled);
     }
 }
Esempio n. 2
0
 /// <summary>
 /// Write to the log
 /// </summary>
 /// <param name="level">Log level</param>
 /// <param name="text">Text with format</param>
 /// <param name="args">Format args</param>
 public static void Write(IPBan.LogLevel level, string text, params object[] args)
 {
     try
     {
         logger?.Log(GetNLogLevel(level), text, args);
     }
     catch
     {
     }
 }
Esempio n. 3
0
 /// <summary>
 /// Write to the log
 /// </summary>
 /// <param name="level">Log level</param>
 /// <param name="ts">Timestamp</param>
 /// <param name="text">Text with format</param>
 /// <param name="args">Format args</param>
 private static void Write(IPBan.LogLevel level, DateTime ts, string text, params object[] args)
 {
     try
     {
         //timeSource.CurrentTime = ts;
         logger?.Log(GetNLogLevel(level), text, args);
     }
     catch
     {
     }
 }
Esempio n. 4
0
        /// <summary>
        /// Write to the log
        /// </summary>
        /// <param name="level">Log level</param>
        /// <param name="ts">Timestamp</param>
        /// <param name="text">Text with format</param>
        /// <param name="args">Format args</param>
        private static void Write(IPBan.LogLevel level, DateTime ts, string text, params object[] args)
        {
            try
            {
#if DEBUG
                if (level == LogLevel.Error || level == LogLevel.Critical || level == LogLevel.Fatal)
                {
                    // System.Diagnostics.Debugger.Break();
                }
#endif

                //timeSource.CurrentTime = ts;
                logger?.Log(GetNLogLevel(level), text, args);
            }
            catch
            {
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Map IPBan log level to NLog log level
        /// </summary>
        /// <param name="logLevel">IPBan log level</param>
        /// <returns>NLog log level</returns>
        public static NLog.LogLevel GetNLogLevel(IPBan.LogLevel logLevel)
        {
            switch (logLevel)
            {
            case IPBan.LogLevel.Critical: return(NLog.LogLevel.Fatal);

            case IPBan.LogLevel.Debug: return(NLog.LogLevel.Debug);

            case IPBan.LogLevel.Error: return(NLog.LogLevel.Error);

            case IPBan.LogLevel.Information: return(NLog.LogLevel.Info);

            case IPBan.LogLevel.Trace: return(NLog.LogLevel.Trace);

            case IPBan.LogLevel.Warning: return(NLog.LogLevel.Warn);

            default: return(NLog.LogLevel.Off);
            }
        }
Esempio n. 6
0
 /// <summary>
 /// Write to the log
 /// </summary>
 /// <param name="level">Log level</param>
 /// <param name="text">Text with format</param>
 /// <param name="args">Format args</param>
 private static void Write(IPBan.LogLevel level, string text, params object[] args)
 {
     Write(level, IPBanService.UtcNow, text, args);
 }