Esempio n. 1
0
        public void Ctor_DeclareLogObjectWithNullFormatter_ExceptionThrown()
        {
            ILogEntryFormatter entryFormatter = null;
            ILogOutput         logOutput      = new FileOutput();

            Assert.Throws <ArgumentNullException>(() => new Log(logOutput, entryFormatter));
        }
Esempio n. 2
0
 public TextWriterLogSink(Stream stream, ILogEntryFormatter formatter = null)
     : this(new StreamWriter(stream), formatter)
 {
     if (stream == null)
     {
         throw new ArgumentNullException("stream");
     }
 }
Esempio n. 3
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="config"></param>
 public override void Initialize(IConfigNode config)
 {
     base.Initialize(config);
     if (this.Formatter == null)
     {
         this.Formatter = new TextFormatter();
     }
 }
Esempio n. 4
0
 public FileLogger(
     ILogEntryFormatter logEntryFormatter,
     ILoggerSettingsRepository loggerSettingsRepository
     )
 {
     _logEntryFormatter        = logEntryFormatter;
     _loggerSettingsRepository = loggerSettingsRepository;
 }
Esempio n. 5
0
 /// <summary>
 /// Internal to make it accessable to unittests. Don't use this constructor unless you know what you're doing!
 /// </summary>
 /// <param name="logOutput"></param>
 /// <param name="logFormatter"></param>
 internal Log(ILogOutput logOutput, ILogEntryFormatter logFormatter)
 {
     if (logOutput == null || logFormatter == null)
     {
         throw new ArgumentNullException("Log Output parameter or Formatter parameter is null.");
     }
     _logOutput    = logOutput;
     _logFormatter = logFormatter;
 }
Esempio n. 6
0
        /// <summary>
        /// LogListener base class.
        /// </summary>
        /// <param name="id">Identifier of the listener.</param>
        /// <param name="name">Name of the listener.</param>
        /// <param name="filter">Filter applied to the incoming log entries.</param>
        /// <param name="formatter">Format used to convert log entry to string.</param>
        protected LogListener(string id, string name, ILogEntryFilter filter, ILogEntryFormatter formatter)
        {
            Id        = id;
            Name      = name;
            Filter    = filter;
            Formatter = formatter;

            IsEnabled = true;
        }
Esempio n. 7
0
        /// <summary>
        /// Sets the formatter which can then be retrieved from the <seealso cref="CurrentFormatter"/> property.
        /// </summary>
        /// <param name="logEntryFormatter">The formatter instance to be set.</param>
        public static void SetFormatter(ILogEntryFormatter logEntryFormatter)
        {
            if (logEntryFormatter == null)
            {
                throw new ArgumentNullException("logEntryFormatter");
            }

            _logEntryFormatter = logEntryFormatter;
        }
        public TextWriterLogSink(TextWriter writer, ILogEntryFormatter formatter = null)
        {
            if (writer == null)
                throw new ArgumentNullException("writer");

            Writer = writer;
            Lock = new ReaderWriterLockSlim();
            Formatter = formatter ?? new LogEntryFormatter();
        }
        public RollingFileLogSink(IRollingFileSettings settings, IRollingFileManager logWriterManager = null, ILogEntryFormatter formatter = null, Verbosity verbosity = Verbosity.All)
        {
            if (settings == null)
                throw new ArgumentNullException("settings");

            _settings = settings;
            _formatter = formatter ?? new LogEntryFormatter();
            _logWriterManager = logWriterManager ?? new RollingFileManager(settings, new LogFolder(settings.BasePath, settings.BaseFileName));

            _verbosity = verbosity;
        }
Esempio n. 10
0
        public TextWriterLogSink(TextWriter writer, ILogEntryFormatter formatter = null)
        {
            if (writer == null)
            {
                throw new ArgumentNullException("writer");
            }

            Writer    = writer;
            Lock      = new ReaderWriterLockSlim();
            Formatter = formatter ?? new LogEntryFormatter();
        }
Esempio n. 11
0
        public FileLogger(
            ILogEntryFormatter logEntryFormatter,
            ILoggerSettingsRepository loggerSettingsRepository
            ) : base(logEntryFormatter)
        {
            Settings = loggerSettingsRepository.Get();

            lock (lockObj)
            {
                using (var streamWriter = new StreamWriter(GetFilePath(), false))
                {
                    streamWriter.WriteLine(string.Empty);
                    streamWriter.Close();
                }
            }
        }
Esempio n. 12
0
 public StringLogSink(ILogEntryFormatter formatter = null) : base(new StringWriter(), formatter)
 {
     LastText = string.Empty;
 }
Esempio n. 13
0
        /// <summary>
        /// Internal to make it accessable to unittests. Don't use this constructor unless you know what you're doing!
        /// </summary>
        /// <param name="logOutput"></param>
        /// <param name="logFormatter"></param>
        internal Log(ILogOutput logOutput, ILogEntryFormatter logFormatter)
        {

            if (logOutput == null || logFormatter == null)
                throw new ArgumentNullException("Log Output parameter or Formatter parameter is null.");
            _logOutput = logOutput;
            _logFormatter = logFormatter;
        }
Esempio n. 14
0
 protected abstract ILogger CreateLogger(string name, ILogEntryFormatter formatter, LogLevel level);
 public TextWriterLogSink(Stream stream, ILogEntryFormatter formatter = null)
     : this(new StreamWriter(stream), formatter)
 {
     if (stream == null)
         throw new ArgumentNullException("stream");
 }
Esempio n. 16
0
 protected AbstractLogger(string name, ILogEntryFormatter formatter, LogLevel level)
 {
     _name      = name;
     _formatter = formatter;
     LogLevel   = level;
 }
Esempio n. 17
0
 protected AbstractLoggerFactory(ILogEntryFormatter formatter, LogLevel level)
 {
     _cachedLoggers = new Hashtable();
     _formatter     = formatter;
     LogLevel       = level;
 }
Esempio n. 18
0
 public ConsoleLogger(ILogEntryFormatter logEntryFormatter) : base(logEntryFormatter)
 {
 }
Esempio n. 19
0
 public LPFMUTLogger(string name, ILogEntryFormatter formatter, LogLevel level)
     : base(name, formatter, level)
 {
 }
Esempio n. 20
0
 public StringLogSink(ILogEntryFormatter formatter = null)
     : base(new StringWriter(), formatter)
 {
     LastText = string.Empty;
 }
Esempio n. 21
0
 public LPFMUTLoggerFactory(ILogEntryFormatter formatter, LogLevel level)
     : base(formatter, level)
 {
 }
Esempio n. 22
0
 public TraceLogger(ILogEntryFormatter logEntryFormatter) : base(logEntryFormatter)
 {
 }
Esempio n. 23
0
 protected override ILogger CreateLogger(string name, ILogEntryFormatter formatter, LogLevel level)
 {
     return(new LPFMUTLogger(name, formatter, level));
 }
Esempio n. 24
0
 public LoggerBase(ILogEntryFormatter logEntryFormatter)
 {
     _logEntryFormatter = logEntryFormatter;
 }
Esempio n. 25
0
        /// <summary>
        ///     Returns a <see cref="String" /> that represents the default string
        ///     representation of this entry.
        /// </summary>
        /// <returns>
        ///     A <see cref="String" /> that represents the current
        ///     <see cref="Object" /> .
        /// </returns>
        public override string ToString()
        {
            ILogEntryFormatter formatter = Formatter ?? DefaultFormatter.Instance;

            return(formatter.FormatEntry(this));
        }