예제 #1
0
        /// <summary>
        /// Set the common options for this writer as well as the default options for the logger
        /// </summary>
        /// <param name="options">Common log options</param>
        public override void SetCommonOptions(LogOptions options)
        {
            base.SetCommonOptions(options);

            _baseLogName = _logDir + "\\" + _commonOptions.AppName;
            LogFile      = _baseLogName + LOG_EXT;
        }
예제 #2
0
 /// <summary>
 /// Set options for all log writers maintained by this logger
 /// </summary>
 /// <param name="options">LogOptions to set for all writers</param>
 public void SetAllOptions(LogOptions options)
 {
     foreach (var writer in _logWriters.Values)
     {
         writer.SetCommonOptions(options);
     }
 }
예제 #3
0
 /// <summary>
 /// Set the log options for the given log writer
 /// </summary>
 /// <param name="writerName">Internal, unique name of the log writer</param>
 /// <param name="options">LogOptions to set for the given writer</param>
 public void SetLogOptions(string writerName, LogOptions options)
 {
     if (_logWriters.ContainsKey(writerName))
     {
         _logWriters[writerName].SetCommonOptions(options);
     }
 }
예제 #4
0
        /// <summary>
        /// Create a logger of the specified type with the given options and writer options
        /// </summary>
        /// <param name="t">Logger type</param>
        /// <param name="commonOptions">Options common to all writers</param>
        /// <param name="options">Log writer options</param>
        public Logger(Type t, LogOptions commonOptions)
        {
            _commonOptions = commonOptions;
            _type          = t;

            Task.Run(() => LogMessages(), _cts.Token);
        }
예제 #5
0
        /// <summary>
        /// Create a new log file writer with the specified name, log directory, and log options.
        /// </summary>
        /// <param name="name">Internal, unique name of the LogWriter</param>
        /// <param name="logDirectory">Directory to create log files in</param>
        /// <param name="common">Log options commmon to all writers</param>
        public LogFileWriter(string name, string logDirectory, LogOptions common) : base(name, common)
        {
            LogDirectory = logDirectory;

            DirectoryInfo dirInfo = Directory.CreateDirectory(LogDirectory);

            _logDir      = dirInfo.FullName;
            _baseLogName = _logDir + "\\" + _commonOptions.AppName;
            LogFile      = _baseLogName + LOG_EXT;
        }
예제 #6
0
 public LogDatabaseWriter(string name, LogOptions common) : base(name, common)
 {
 }
예제 #7
0
 /// <summary>
 /// Create a new log file writer with the specified name and log options
 /// </summary>
 /// <param name="name">Internal, unique name of the LogWriter</param>
 /// <param name="common">Log options commmon to all writers</param>
 public LogFileWriter(string name, LogOptions common) : this(name, DEFAULT_LOG_DIR, common)
 {
 }
예제 #8
0
 /// <summary>
 /// Get a logger for the given type
 /// </summary>
 /// <typeparam name="T">The type of the class this logger is for</typeparam>
 /// <param name="commonOptions">The options common to all log writers</param>
 /// <param name="options">Log options detailing the types of log writers to include. Default is just LogFileWriter</param>
 /// <returns>Logger for the given class with the specified writers and options</returns>
 public static Logger GetLogger <T>(LogOptions commonOptions)
 {
     return(new Logger(typeof(T), commonOptions));
 }
예제 #9
0
 /// <summary>
 /// Set the default options for the global logger and all future logger instances
 /// </summary>
 /// <param name="options">Common log options</param>
 public static void SetDefaults(LogOptions options)
 {
     _defaults = options;
     _globalLogger.SetAllOptions(_defaults);
 }
예제 #10
0
 // Allow static logging to occur without ever providing options, by using the default options
 static LogManager()
 {
     _defaults     = LogOptions.Default;
     _globalLogger = GetLogger <Logger>(_defaults);
     _globalLogger.AddLogWriter(LogFileWriter.Default);
 }
예제 #11
0
 public LogEventViewerWriter(string name, LogOptions common) : base(name, common)
 {
 }
예제 #12
0
파일: LogWriter.cs 프로젝트: Lyelt/Logger
 /// <summary>
 /// Set the options for this log writer which are common to all log writers
 /// </summary>
 /// <param name="options">Log options to set</param>
 public virtual void SetCommonOptions(LogOptions options)
 {
     _commonOptions = options;
 }
예제 #13
0
파일: LogWriter.cs 프로젝트: Lyelt/Logger
 /// <summary>
 /// Create a new log writer with the given name and common options
 /// </summary>
 /// <param name="name">Unique name of the log writer</param>
 /// <param name="options">Options for this log writer</param>
 public LogWriter(string name, LogOptions options)
 {
     Name = name;
     SetCommonOptions(options);
 }