コード例 #1
0
ファイル: Halite.cs プロジェクト: vikstrous/Halite-II
 public static void Information(string message, LogingLevel level)
 {
     if (!string.IsNullOrEmpty(_logPath) && _level == level)
     {
         File.AppendAllLines(_logPath, new [] { string.Format("{0}: {1}", DateTime.Now.ToString("t"), message) });
     }
 }
コード例 #2
0
ファイル: Halite.cs プロジェクト: vikstrous/Halite-II
 /// <summary>
 /// File must exist
 /// </summary>
 public static void Setup(string logPath, LogingLevel level)
 {
     _logPath = logPath;
     _level   = level;
     if (File.Exists(_logPath))
     {
         File.Delete(_logPath);
     }
 }
コード例 #3
0
        public static void Log(string message, LogingLevel loggingLevel)
        {
            log4net.Config.XmlConfigurator.Configure();
            switch (loggingLevel)
            {
            case LogingLevel.All:
                if (_Logger.Logger.IsEnabledFor(log4net.Core.Level.All))
                {
                    _Logger.Debug(message);
                }
                break;

            case LogingLevel.Debug:
                _Logger.Debug(message);
                break;

            case LogingLevel.Info:
                _Logger.Info(message);
                break;

            case LogingLevel.Warn:
                _Logger.Warn(message);
                break;

            case LogingLevel.Error:
                _Logger.Error(message);
                break;

            case LogingLevel.Fatal:
                _Logger.Fatal(message);
                break;

            case LogingLevel.Off:
                break;

            default:
                break;
            }
        }
コード例 #4
0
        public static void Log(string messageText, Exception ex, LogingLevel loggingLevel)
        {
            var buffer = new StringBuilder();

            buffer.AppendFormat("{0}Spectrum - Back Office{0}", Environment.NewLine);

            if (!string.IsNullOrEmpty(messageText))
            {
                buffer.AppendFormat("User Message   : {0}{1}", messageText, Environment.NewLine);
            }

            buffer.AppendFormat("Date           : {0}{1}", DateTime.Now, Environment.NewLine);
            buffer.AppendFormat("Error Type     : {0} -> {1}{2}", ex.GetType().Name, ex.TargetSite.Name, Environment.NewLine);
            buffer.AppendFormat("Error Message  : {0}{1}", ex.Message, Environment.NewLine);
            buffer.AppendFormat("StackTrace     : {0}", Environment.NewLine);

            foreach (var stackTrace in ex.StackTrace.Split('\n'))
            {
                buffer.AppendFormat("                 {0}{1}", stackTrace.Trim(), Environment.NewLine);
            }

            while (ex.InnerException != null)
            {
                ex = ex.InnerException;

                buffer.AppendFormat("Caused By{0}", Environment.NewLine);
                buffer.AppendFormat("Error Type     : {0} -> {1}{2}", ex.GetType().Name, ex.TargetSite.Name, Environment.NewLine);
                buffer.AppendFormat("Error Message  : {0}{1}", ex.Message, Environment.NewLine);
                buffer.AppendFormat("StackTrace     : {0}", Environment.NewLine);

                foreach (var stackTrace in ex.StackTrace.Split('\n'))
                {
                    buffer.AppendFormat("                 {0}{1}", stackTrace.Trim(), Environment.NewLine);
                }

                buffer.AppendFormat(Environment.NewLine);
            }
            Log(buffer.ToString(), loggingLevel);
        }
コード例 #5
0
ファイル: Halite.cs プロジェクト: vikstrous/Halite-II
 public static void Error(Exception exception, LogingLevel level)
 {
     Log.Information(string.Format("ERROR: {0} {1}", exception.Message, exception.StackTrace), level);
 }
コード例 #6
0
 public static void Log(Exception ex, LogingLevel loggingLevel)
 {
     Log(string.Empty, ex, loggingLevel);
 }