Esempio n. 1
0
        public void ConstructLineTest()
        {
            ILogConstructor target = CreateLogConstructor(); // TODO: Initialize to an appropriate value
            Exception       ex     = null;

            try
            {
                throw new Exception(exception);
            }
            catch (Exception ex1)
            {
                ex = ex1;
            }

            LogItem item = new LogItem(category, level, message, ids, ex);

            LogLevel.SetLevel(LogLevel.Error, "Error");

            string        actual;
            StringBuilder sb = new StringBuilder();

            target.ConstructLine(sb, item);
            actual = sb.ToString();
            Assert.IsTrue(stringCriteria(actual));
        }
Esempio n. 2
0
 public LogFileWriter(ILogConstructor constructor, IOptions options)
 {
     this.constructor = constructor;
     flushTimeout = options.GetInt("LogFileFlush", Timeout.Infinite);
     if (flushTimeout == 0)
     {
         flushTimeout = Timeout.Infinite;
     }
     forceFlush = TimeSpan.FromSeconds((double)flushTimeout / 500);
     filename = options.Get("LogFilename", "./logs.log");
     rotationSize = (1 << 20) * options.GetInt("LogRotationSizeMb", 5);
     rotationFiles = options.GetInt("LogRotationFiles", 5);
     var append = options["LogFileAppend"].ToLower() == "true";
     if (!append && File.Exists(filename))
     {
         Rotate();
     }
     buffer = new StringBuilder(BufferSize + 256);
     lastFlush = DateTime.Now;
 }
Esempio n. 3
0
        public LogFileWriter(ILogConstructor constructor, IOptions options)
        {
            this.constructor = constructor;
            flushTimeout     = options.GetInt("LogFileFlush", Timeout.Infinite);
            if (flushTimeout == 0)
            {
                flushTimeout = Timeout.Infinite;
            }
            forceFlush    = TimeSpan.FromSeconds((double)flushTimeout / 500);
            filename      = options.Get("LogFilename", "./logs.log");
            rotationSize  = (1 << 20) * options.GetInt("LogRotationSizeMb", 5);
            rotationFiles = options.GetInt("LogRotationFiles", 5);
            var append = options["LogFileAppend"].ToLower() == "true";

            if (!append && File.Exists(filename))
            {
                Rotate();
            }
            buffer    = new StringBuilder(BufferSize + 256);
            lastFlush = DateTime.Now;
        }
Esempio n. 4
0
 void AddConstructor(ILogConstructor constructor)
 {
     AddStringAppender();
     this.constructor.Add(constructor);
 }
 void AddConstructor(ILogConstructor constructor)
 {
     AddStringAppender();
     this.constructor.Add(constructor);
 }
Esempio n. 6
0
 public void Add(ILogConstructor next)
 {
     constructList.Add(next);
 }
 public void Add(ILogConstructor next)
 {
     constructList.Add(next);
 }