public PerformanceCounterDefinition(string path) { Must.NotBeNull(() => path); if (!path.StartsWith("\\")) { throw new ArgumentException("'path' must begin with a '\\'"); } var keyTokens = path.Split(KeySeparator); if (keyTokens.Length < 3) { throw new ArgumentException("'path' must contain a Category and Counter", path); } CategoryName = keyTokens[1]; CounterName = keyTokens[2]; if (CategoryName.Contains("(") && CategoryName.Contains(")")) { var categoryNameTokens = CategoryName.Split('(', ')'); CategoryName = categoryNameTokens[0]; InstanceName = categoryNameTokens[1]; } }
private bool ValidCategory() { if (string.IsNullOrEmpty(CategoryName)) { return(false); } var parts = CategoryName.Split("."); return(string.Equals(parts[0], "Historian")); }
public void Log <TState>(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func <TState, Exception, string> formatter) { if (IsEnabled(logLevel)) { lock (_lockObj) { Console.ForegroundColor = LogLevelColors[logLevel]; Console.Write($"[{CategoryName.Split('.').Last()}] "); Console.ForegroundColor = ConsoleColor.Gray; Console.WriteLine(formatter(state, exception)); } } }