Esempio n. 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;
        }
Esempio n. 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);
     }
 }
Esempio n. 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);
     }
 }
Esempio n. 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);
        }
Esempio n. 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;
        }
Esempio n. 6
0
 public LogDatabaseWriter(string name, LogOptions common) : base(name, common)
 {
 }
Esempio n. 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)
 {
 }
Esempio n. 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));
 }
Esempio n. 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);
 }
Esempio n. 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);
 }
Esempio n. 11
0
 public LogEventViewerWriter(string name, LogOptions common) : base(name, common)
 {
 }
Esempio n. 12
0
 /// <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;
 }
Esempio n. 13
0
 /// <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);
 }