Changeset 1935 for trunk/sources
- Timestamp:
- 05/28/09 17:24:12 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Tracing/3.2/HiveLogger.cs
r1933 r1935 1 1 using System; 2 using System.Collections.Generic;3 using System.Linq;4 using System.Text;5 2 using HeuristicLab.Tracing.Properties; 3 using log4net; 4 using System.Diagnostics; 5 using log4net.Config; 6 6 using System.IO; 7 using log4net.Config;8 7 9 8 namespace HeuristicLab.Tracing { 10 public class HiveLogger: Logger { 11 protected new static void Configure() { 9 public class HiveLogger { 10 protected static bool IsConfigured = false; 11 protected static void Configure() { 12 12 if (IsConfigured) return; 13 13 IsConfigured = true; … … 22 22 Info("Hive Logging initialized " + DateTime.Now); 23 23 } 24 25 public static ILog GetDefaultLogger(int nParents) { 26 Configure(); 27 StackFrame frame = new StackFrame(nParents + 1); 28 return LogManager.GetLogger(frame.GetMethod().DeclaringType); 29 } 30 31 public static ILog GetDefaultLogger() { 32 Configure(); 33 StackFrame frame = new StackFrame(1); 34 return LogManager.GetLogger(frame.GetMethod().DeclaringType); 35 } 36 37 public static void Debug(object message) { 38 GetDefaultLogger(1).Debug(message); 39 } 40 41 public static void Info(object message) { 42 GetDefaultLogger(1).Info(message); 43 } 44 45 public static void Warn(object message) { 46 GetDefaultLogger(1).Warn(message); 47 } 48 49 public static void Error(object message) { 50 GetDefaultLogger(1).Error(message); 51 } 52 53 public static void Fatal(object message) { 54 GetDefaultLogger(1).Fatal(message); 55 } 56 57 public static void Debug(Type type, object message) { 58 Configure(); 59 LogManager.GetLogger(type).Debug(message); 60 } 61 62 public static void Info(Type type, object message) { 63 Configure(); 64 LogManager.GetLogger(type).Info(message); 65 } 66 67 public static void Warn(Type type, object message) { 68 Configure(); 69 LogManager.GetLogger(type).Warn(message); 70 } 71 72 public static void Error(Type type, object message) { 73 Configure(); 74 LogManager.GetLogger(type).Error(message); 75 } 76 77 public static void Fatal(Type type, object message) { 78 Configure(); 79 LogManager.GetLogger(type).Fatal(message); 80 } 81 82 public static void Debug(object message, Exception exception) { 83 GetDefaultLogger(1).Debug(message, exception); 84 } 85 86 public static void Info(object message, Exception exception) { 87 GetDefaultLogger(1).Info(message, exception); 88 } 89 90 public static void Warn(object message, Exception exception) { 91 GetDefaultLogger(1).Warn(message, exception); 92 } 93 94 public static void Error(object message, Exception exception) { 95 GetDefaultLogger(1).Error(message, exception); 96 } 97 98 public static void Fatal(object message, Exception exception) { 99 GetDefaultLogger(1).Fatal(message, exception); 100 } 101 102 public static void Debug(Type type, object message, Exception exception) { 103 Configure(); 104 LogManager.GetLogger(type).Debug(message, exception); 105 } 106 107 public static void Info(Type type, object message, Exception exception) { 108 Configure(); 109 LogManager.GetLogger(type).Info(message, exception); 110 } 111 112 public static void Warn(Type type, object message, Exception exception) { 113 Configure(); 114 LogManager.GetLogger(type).Warn(message, exception); 115 } 116 117 public static void Error(Type type, object message, Exception exception) { 118 Configure(); 119 LogManager.GetLogger(type).Error(message, exception); 120 } 121 122 public static void Fatal(Type type, object message, Exception exception) { 123 Configure(); 124 LogManager.GetLogger(type).Fatal(message, exception); 125 } 126 24 127 } 25 128 }
Note: See TracChangeset
for help on using the changeset viewer.