public void Init() { Metric.Config.WithHttpEndpoint("http://localhost:2581/").WithSystemCounters(); //XXX use config to get this info var registryFactory = LogRegistryFactory.Create(); var parserFactory = LogParserFactory.GetParserForFileExtension("xml"); IPrinterFactory printerFactory; if (config.ExtraConfigs != null && config.ExtraConfigs.ContainsKey("printToFile") && !string.IsNullOrWhiteSpace(config.ExtraConfigs["printToFile"])) { // Note: this just sets a default. Configs can change the file printerFactory = PrinterFactory.CrateFileFactory(config.ExtraConfigs["printToFile"]); } else { printerFactory = PrinterFactory.CrateConsoleFactory(); } registry = registryFactory.Create(); logFileParser = parserFactory.Create(registry, config); printer = printerFactory.Create(registry, config); }
/// <summary> /// Set the registy that logs will be saved to once parsed. /// </summary> /// <param name="registry">The registy that logs will be saved to once parsed.</param> public void SetRegistry(ILogRegistry registry) { if (this.registry != null) { throw new InvalidOperationException("Can only set registry once"); } this.registry = registry; }
/// <summary> /// Get logs, ordered by timestamp. /// </summary> /// <param name="registry">Log registry</param> /// <returns>Observable of all log entries by time. Entries missing timestamps are not included.</returns> public static IObservable <ILogEntry> GetByTimetstamp(this ILogRegistry registry) { getByTimestampCounter.Increment(); return(from log in registry.Logs where log.IsValidForTimestamp() select log); }
public void Setup() { mockLogRegistry = Substitute.For <ILogRegistry>(); logConfig = new LogConfig() { TimestampPath = "TimePath", LogMessagePath = "MessagePath" }; }
public IPrinter Create(ILogRegistry registry, LogConfig config) { creationCounter.Increment("file"); var printer = new FilePrinter(defaultPath); printer.SetRegistry(registry); printer.SetConfig(config); return(printer); }
public IPrinter Create(ILogRegistry registry, LogConfig config) { creationCounter.Increment("console"); var printer = new ConsolePrinter(); printer.SetRegistry(registry); printer.SetConfig(config); return(printer); }
public ILogParser Create(ILogRegistry registry, LogConfig config) { creationCounter.Increment(); var parser = new XMLLogParser(); parser.SetRegistry(registry); parser.SetConfig(config); return(parser); }
/// <summary> /// Get logs by a specific attribute. /// </summary> /// <param name="registry">Log registry</param> /// <param name="attribute">The attribute to get entries by.</param> /// <returns>Logs grouped by the specified attribute.</returns> public static IObservable <IGroupedObservable <object, ILogEntry> > GetBy(this ILogRegistry registry, LogAttribute attribute) { getByCounter.Increment(attribute.ToString()); if (attribute == LogAttribute.Timestamp) { return(null); } // Special case to ensure that message and timestamp (which doesn't work here anyway) match the expected types return(from log in registry.Logs where log.HasAttribute(attribute) && (log.IsValid || !(attribute == LogAttribute.Message && !(log.GetAttribute <object>(attribute) is string))) group log by log.GetAttribute <object>(attribute)); }
public void Setup() { logRegistry = Substitute.For <ILogRegistry>(); logEntry = Substitute.For <ILogEntry>(); failedLogEntry = Substitute.For <ILogEntry>(); logConfig = new LogConfig() { TimestampPath = "!time", LogMessagePath = "!log" }; SetupLogEntry(logEntry, true); SetupLogEntry(failedLogEntry, false); }