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)); }
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; }
void AddConstructor(ILogConstructor constructor) { AddStringAppender(); this.constructor.Add(constructor); }
public void Add(ILogConstructor next) { constructList.Add(next); }