public SendDailyMetricsEmail( IConfigurationService configurationManager, ILogService logger, IApprenticeshipMetricsRepository apprenticeshipMetricsRepository, ITraineeshipMetricsRepository traineeshipMetricsRepository, IUserMetricsRepository userMetricsRepository, IExpiringDraftsMetricsRepository expiringDraftsMetricsRepository, IApplicationStatusAlertsMetricsRepository applicationStatusAlertsMetricsRepository, ISavedSearchAlertMetricsRepository savedSearchAlertMetricsRepository, IContactMessagesMetricsRepository contactMessagesMetricsRepository, ISavedSearchesMetricsRepository savedSearchesMetricsRepository, ICandidateMetricsRepository candidateMetricsRepository, IVacancyMetricsProvider vacancyMetricsProvider, IAuditMetricsRepository auditMetricsRepository) { _logger = logger; _apprenticeshipMetricsRepository = apprenticeshipMetricsRepository; _traineeshipMetricsRepository = traineeshipMetricsRepository; _userMetricsRepository = userMetricsRepository; _expiringDraftsMetricsRepository = expiringDraftsMetricsRepository; _applicationStatusAlertsMetricsRepository = applicationStatusAlertsMetricsRepository; _savedSearchAlertMetricsRepository = savedSearchAlertMetricsRepository; _contactMessagesMetricsRepository = contactMessagesMetricsRepository; _savedSearchesMetricsRepository = savedSearchesMetricsRepository; _candidateMetricsRepository = candidateMetricsRepository; _vacancyMetricsProvider = vacancyMetricsProvider; _auditMetricsRepository = auditMetricsRepository; _monitorConfiguration = configurationManager.Get <MonitorConfiguration>(); _emailConfiguration = configurationManager.Get <EmailConfiguration>(); _validNumberOfDaysSinceUserActivity = _monitorConfiguration.ValidNumberOfDaysSinceUserActivity; }
/// <summary> /// Populates a configuration object with any missing endpoints. /// </summary> /// <param name="config"></param> /// <returns></returns> async Task <MonitorConfiguration> AddMissingEndpoints(MonitorConfiguration config) { var endpoints = await GetServiceEndpointsAsync(config); if (endpoints == null) { return(config); } if (config.Endpoints == null) { config.Endpoints = new Dictionary <string, MonitorEndpointConfiguration>(); } foreach (var endpoint in endpoints) { if (config.Endpoints.ContainsKey(endpoint.Name) == false) { config.Endpoints[endpoint.Name] = new MonitorEndpointConfiguration(); } } foreach (var endpoint in config.Endpoints.ToList()) { if (endpoints.Any(i => i.Name == endpoint.Key) == false) { config.Endpoints.Remove(endpoint.Key); } } return(config); }
/// <summary> /// Invoked when the configuration is changed. /// </summary> /// <param name="config"></param> /// <returns></returns> async Task ConfigChanged(MonitorConfiguration config) { logger.Information("Configuration for {ServiceName} changed to {@Config}.", this.GetActorId().GetStringId(), config); var endpoints = await GetServiceEndpointsAsync(config); if (endpoints == null) { throw new InvalidOperationException("Unable to obtain service endpoints."); } // unregister all known endpoint reminders foreach (var endpoint in endpoints) { await TryUnregisterReminderAsync(string.Format(EndpointReminderFormat, endpoint.Name)); } // register new reminders if (config != null && config.Endpoints != null) { foreach (var endpoint in endpoints) { var c = config.Endpoints?.GetOrDefault(endpoint.Name); if (c != null && c.ServerName != null && c.ServerFarmName != null) { await RegisterReminderAsync( string.Format(EndpointReminderFormat, endpoint.Name), Encoding.UTF8.GetBytes(endpoint.Name), TimeSpan.FromSeconds(1), c.Interval ?? TimeSpan.FromSeconds(30)); } } } }
public void TestMultithreadWriteToLogFile() { var tmpFolder = System.Environment.GetFolderPath(System.Environment.SpecialFolder.CommonApplicationData) + @"\" + Guid.NewGuid().ToString(); var conf = new MonitorConfiguration() { LogLevel = "Info", LogFilePath = tmpFolder + @"\test.log" }; var logWriter = new FileLogWriter(conf); Task[] tasks = new Task[100]; for (int i = 0; i < tasks.Length; i++) { tasks[i] = Task.Run(() => { Console.WriteLine(Process.GetCurrentProcess().Threads.Count); String logContent = Guid.NewGuid().ToString(); logWriter.Write(LogLevel.Info, logContent); }); } Task.WaitAll(tasks); Directory.Delete(tmpFolder, true); }
public void Execute() { ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, sslPolicyErrors) => true; var configuration = new MonitorConfiguration { PingUrls = { Urls = new[] { "http://www.google.com" }, MaximumWaitTimeSeconds = 10 } }; var subject = new PingUrlsStep(); var workItem = new MonitorWorkItem(configuration); var context = Substitute.For <ITaskExecutionContext <MonitorWorkItem> >(); context.WorkItem.Returns(workItem); subject.Execute(context); string messages = string.Join(Environment.NewLine, workItem.GetEntries(Target.Service).Select(x => x.Message)); Assert.IsEmpty(messages); }
private void TestBrightness() { var(getResult, minimum, current, maximum) = MonitorConfiguration.GetBrightness(Handle, Capability.IsHighLevelBrightnessSupported); var isGetSuccess = (getResult.Status == AccessStatus.Succeeded); var isValid = (minimum < maximum) && (minimum <= current) && (current <= maximum); GetBrightness = $"Success: {isGetSuccess}" + (isGetSuccess ? $", Valid: {isValid} (Minimum: {minimum}, Current: {current}, Maximum: {maximum})" : string.Empty); var difference = (uint)(DateTime.Now.Ticks % 6 + 5); // Integer from 5 to 10 var expected = difference; if (isGetSuccess && isValid) { expected = (current - minimum > maximum - current) ? current - difference : current + difference; expected = Math.Min(maximum, Math.Max(minimum, expected)); } var setResult = MonitorConfiguration.SetBrightness(Handle, expected, Capability.IsHighLevelBrightnessSupported); var isSetSuccess = (setResult.Status == AccessStatus.Succeeded); var(_, _, actual, _) = MonitorConfiguration.GetBrightness(Handle, Capability.IsHighLevelBrightnessSupported); SetBrightness = $"Success: {isSetSuccess}" + (isSetSuccess ? $", Match: {expected == actual} (Expected: {expected}, Actual: {actual})" : string.Empty); if (isSetSuccess) { MonitorConfiguration.SetBrightness(Handle, current, Capability.IsHighLevelBrightnessSupported); } }
public void TestLog() { var conf = new MonitorConfiguration() { LogLevel = "Info" }; var logWriter = new TestLogWriter(); Logger.Init(conf, new LogWriter[] { logWriter }); Logger.Verbose("Trival"); Assert.IsNull(logWriter.Msg); Logger.Info("Formated information: {0}", "Nothing"); Assert.IsTrue(logWriter.Msg.Contains("Formated information")); Assert.AreEqual(LogLevel.Info, logWriter.Level); Console.WriteLine(logWriter.Msg); try { RaiseException(); } catch(Exception e) { Logger.Error(e); //Check call stack is logged. Assert.IsTrue(logWriter.Msg.Contains("at UnitTest.LoggerTest.TestLog()")); Console.WriteLine(logWriter.Msg); } }
public Monitor(IControlContainer container, IConfiguration configuration) : base(container) { _monitorConfiguration = configuration == null ? new MonitorConfiguration() : configuration.GetSection("Monitor").Get <MonitorConfiguration>(); Init(container); }
public void TestMultithreadWriteToLogFile() { var tmpFolder = System.Environment.GetFolderPath(System.Environment.SpecialFolder.CommonApplicationData) + @"\" + Guid.NewGuid().ToString(); var conf = new MonitorConfiguration() { LogLevel = "Info", LogFilePath = tmpFolder + @"\test.log" }; var logWriter = new FileLogWriter(conf); Task[] tasks = new Task[100]; for(int i = 0; i < tasks.Length; i++) { tasks[i] = Task.Run(() => { Console.WriteLine(Process.GetCurrentProcess().Threads.Count); String logContent = Guid.NewGuid().ToString(); logWriter.Write(LogLevel.Info, logContent); }); } Task.WaitAll(tasks); Directory.Delete(tmpFolder, true); }
public void TestLog() { var conf = new MonitorConfiguration() { LogLevel = "Info" }; var logWriter = new TestLogWriter(); Logger.Init(conf, new LogWriter[] { logWriter }); Logger.Verbose("Trival"); Assert.IsNull(logWriter.Msg); Logger.Info("Formated information: {0}", "Nothing"); Assert.IsTrue(logWriter.Msg.Contains("Formated information")); Assert.AreEqual(LogLevel.Info, logWriter.Level); Console.WriteLine(logWriter.Msg); try { RaiseException(); } catch (Exception e) { Logger.Error(e); //Check call stack is logged. Assert.IsTrue(logWriter.Msg.Contains("at UnitTest.LoggerTest.TestLog()")); Console.WriteLine(logWriter.Msg); } }
public async Task <MonitorConfiguration> SetConfig(MonitorConfiguration config) { await StateManager.SetStateAsync("Configuration", await AddMissingEndpoints(config)); await ConfigChanged(config); return(await GetConfig()); }
public Monitor(SlackClient client, MonitorConfiguration configuration) { var pollPeriod = TimeSpan.FromMilliseconds(configuration.PollPeriod); _timer = new Timer(Poll, state: null, dueTime: TimeSpan.FromSeconds(1), period: pollPeriod); Client = client; }
protected MonitoringTask(MonitorConfiguration conf) { this.conf = conf; foreach (var mgmtObjConf in conf.MgmtObjects) { mgmtObjects.Add(MgmtObject.CreateInstance(mgmtObjConf)); } }
public static void Init(MonitorConfiguration conf) { Init(conf, new LogWriter[] { new FileLogWriter(conf), new EventLogWriter(conf) }); }
private void UpdateMonitor(IStatusMonitor existingMonitor, MonitorConfiguration monitorConfiguration) { var updatedMonitor = StatusMonitorFactory.Create(monitorConfiguration, _networkUtil); updatedMonitor.CopyStatusFrom(existingMonitor); _statusMonitorConfiguration.Monitors.Remove(existingMonitor); _statusMonitorConfiguration.Monitors.Add(updatedMonitor); }
public frmOptions(MonitorConfiguration configuration) { InitializeComponent(); this.Configuration = configuration; this.DisplayConfiguration(); }
protected MonitoringTask(MonitorConfiguration conf) { this.conf = conf; foreach (var mgmtObjConf in conf.MgmtObjects) { mgmtObjects.Add(MgmtObject.CreateInstance(mgmtObjConf)); } }
public void ApplyConfig(MonitorConfiguration config) { if (_config != null) { throw new InvalidOperationException("You can apply config only once!"); } _config = config; }
public static MonitoringTask CreateInstance(MonitorConfiguration conf) { if (conf == null) { throw new ArgumentNullException("conf"); } var instance = new MonitoringTask(conf); return instance; }
public void TestZeroLogWriter() { var conf = new MonitorConfiguration() { LogLevel = "Infoasdfasdf" }; Logger.Init(conf, new LogWriter[0]); Logger.Info("Test"); }
public void TestLogLevelConfigure() { var conf = new MonitorConfiguration() { LogLevel = "Infoasdfasdf" }; var logWriter = new TestLogWriter(); Logger.Init(conf, new LogWriter[] { logWriter }); Logger.Info("Test"); Assert.AreEqual(LogLevel.Info, logWriter.Level); }
public static void Init(MonitorConfiguration conf, IList <LogWriter> writers) { lock (instanceLock) { if (instance == null) { instance = new Logger(conf); instance.AddWriters(writers); } } }
public static MonitoringTask CreateInstance(MonitorConfiguration conf) { if (conf == null) { throw new ArgumentNullException("conf"); } var instance = new MonitoringTask(conf); return(instance); }
public async Task <IActionResult> SetMonitor(string serviceName, [FromBody] MonitorConfiguration config) { if (string.IsNullOrWhiteSpace(serviceName)) { return(BadRequest()); } var n = new Uri("fabric:/" + serviceName); var p = ActorProxy.Create <IMonitorActor>(new ActorId(n.ToString())); return(Ok(await p.SetConfig(config))); }
public void TestLogLevelConfigure() { var conf = new MonitorConfiguration() { LogLevel = "Infoasdfasdf" }; var logWriter = new TestLogWriter(); Logger.Init(conf, new LogWriter[] { logWriter }); Logger.Info("Test"); Assert.AreEqual(LogLevel.Info, logWriter.Level); }
private void btnOptions_Click(object sender, EventArgs e) { frmOptions options = new frmOptions(this.Configuration); var result = options.ShowDialog(this); if(result == DialogResult.OK) { this.Configuration = options.Configuration; ConfigManager.SaveConfig("MonitorConfiguration.xml", this.Configuration); // Disconnect and reconnect to new servers } }
public void TestMonitorTask() { var watcher = System.Diagnostics.Stopwatch.StartNew(); MonitorConfiguration conf = MonitorConfiguration.Load(@"..\..\..\EnhancedMonitoring\Configuration\EnhancedMonitoringProviderConfig.xml"); conf.LogFilePath = @"C:\ProgramData\Enhanced Monitoring\log\monitor.log"; conf.LogLevel = "Verbose"; Logger.Init(conf); MonitoringTask task = MonitoringTask.CreateInstance(conf as MonitorConfiguration); task.Run(); Console.WriteLine(String.Format("Elapsed: {0}ms", watcher.ElapsedMilliseconds)); }
public static IStatusMonitor Create(MonitorConfiguration configuration, INetworkUtil networkUtil) { switch (configuration.Type) { case "Port": return(new PortStatusMonitor(networkUtil, configuration)); case "HTTP": return(new HttpStatusMonitor(configuration)); default: return(new EmptyStatusMonitor()); } }
public async Task PopulateAsync() { System = GetSystem(); var sw = new Stopwatch(); var tasks = new[] { GetTask(nameof(DeviceItems), () => DeviceItems = DeviceContext.EnumerateMonitorDevices().ToArray()), GetTask(nameof(DisplayMonitorItems), async() => { if (OsVersion.Is10Build17134OrGreater) { DisplayMonitorItems = await DisplayMonitor.GetDisplayMonitorsAsync(); } }), GetTask(nameof(DisplayConfigItems), () => DisplayConfigItems = DisplayConfig.EnumerateDisplayConfigs().ToArray()), GetTask(nameof(InstalledItems), () => InstalledItems = DeviceInformation.EnumerateInstalledMonitors().ToArray()), GetTask(nameof(PhysicalItems), () => PhysicalItems = DeviceContext.GetMonitorHandles().ToDictionary( x => x, x => MonitorConfiguration.EnumeratePhysicalMonitors(x.MonitorHandle, true) .Select(x => new PhysicalItemPlus(x)) .ToArray())), GetTask(nameof(DesktopItems), () => DesktopItems = MSMonitor.EnumerateDesktopMonitors().ToArray()) }; sw.Start(); ElapsedTime = await Task.WhenAll(tasks); sw.Stop(); Task <string> GetTask(string name, Action action) => Task.Run(() => { action.Invoke(); var elapsed = sw.Elapsed; return($@"{name,-14} -> {elapsed.ToString($@"{(elapsed.Minutes > 0 ? @"m\:" : string.Empty)}s\.fff")}"); }); }
private void RunMonitoringTask(MonitorConfiguration conf) { Logger.Info("Start monitoring task"); DateTime start = DateTime.Now; MonitoringTask task = MonitoringTask.CreateInstance(conf); task.Run(); Logger.Info("Monitoring task finished"); TimeSpan elapsed = DateTime.Now.Subtract(start); //Substract elapsed time to get the task running exaclty aliging to refresh rate. long interval = Math.Max(conf.RefreshRate, MIN_REFRESH_RATE) * 1000; long timeToWait = interval - (long)elapsed.TotalMilliseconds % interval; //Trigger next task timer.Change(timeToWait, Timeout.Infinite); }
protected override void OnStart(string[] args) { var configFilePath = String.Format(@"{0}\{1}\{2}", System.Environment.GetFolderPath(System.Environment.SpecialFolder.CommonApplicationData), "Enhanced Monitoring", "EnhancedMonitoringProviderConfig.xml"); var defaultLogPath = String.Format(@"{0}\{1}\{2}\{3}", System.Environment.GetFolderPath(System.Environment.SpecialFolder.CommonApplicationData), "Enhanced Monitoring", "log", "monitor.log"); MonitorConfiguration conf = MonitorConfiguration.Load(configFilePath); conf.LogFilePath = conf.LogFilePath ?? defaultLogPath; Logger.Init(conf); timer = new Timer(_ => this.RunMonitoringTask(conf), null, 0, Timeout.Infinite); Logger.Info("Monitoring service started"); }
private void SaveWindows() { if (updatingWindows) { return; } lock (lockObject) { var desktopWindows = WindowHelpers.GetDesktopWindows(); var monitorConfiguration = new MonitorConfiguration() { MonitorCount = monitorCount, Windows = desktopWindows }; monitorConfigurations[monitorCount] = monitorConfiguration; } }
public void TestLoadConfiguration() { var conf = MonitorConfiguration.Load(@"..\..\SampleMonitor.xml"); Assert.IsNotNull(conf); Assert.IsNotNull(conf.Version); Console.WriteLine(conf.Version); Assert.AreEqual(60, conf.RefreshRate); Assert.AreEqual(700, conf.MaxValueLength); Assert.IsNotNull(conf.Kvp); Assert.AreEqual(200, conf.Kvp.WriteInterval); Assert.IsTrue(conf.Kvp.BatchMode); Assert.IsNotNull(conf.SupportedVMDetector); Assert.IsNotNull(conf.SupportedVMDetector.GuestDataItemKey); Assert.IsNotNull(conf.MgmtObjects); var mgmtObj = conf.MgmtObjects.FirstOrDefault(); Assert.IsNotNull(mgmtObj); Assert.IsTrue(mgmtObj.SuppressError); Assert.IsNotNull(mgmtObj.Namespace); Assert.IsNotNull(mgmtObj.Where); Assert.IsNotNull(mgmtObj.From); Assert.IsNotNull(mgmtObj.WhereArgs); Assert.IsTrue(mgmtObj.WhereArgs.FirstOrDefault().Escape); Assert.IsNotNull(mgmtObj.WhereArgs.FirstOrDefault()); Assert.IsNotNull(mgmtObj.PerfCounters); var counter = mgmtObj.PerfCounters.FirstOrDefault(); Assert.IsNotNull(counter); Assert.IsNotNull(counter.Select); Assert.IsNotNull(counter.As); var dynamicMemMgmtObj = conf.MgmtObjects.Where(m => m.Type == MgmtObjectType.DynamicMemory).FirstOrDefault(); Assert.IsNotNull(dynamicMemMgmtObj); Assert.AreEqual(MgmtObjectReturnValueType.Single, dynamicMemMgmtObj.ReturnValueType); }
public void TestWriteToLogFile() { var tmpFolder = System.Environment.GetFolderPath(System.Environment.SpecialFolder.CommonApplicationData) + @"\" + Guid.NewGuid().ToString(); var conf = new MonitorConfiguration() { LogLevel = "Info", LogFilePath = tmpFolder + @"\test.log" }; var logWriter = new FileLogWriter(conf); String logContent = Guid.NewGuid().ToString(); logWriter.Write(LogLevel.Info, logContent); Assert.IsTrue(File.Exists(conf.LogFilePath)); String log = File.ReadAllText(conf.LogFilePath); Assert.IsTrue(log.Contains(logContent)); Directory.Delete(tmpFolder, true); }
/// <summary> /// Initializes a new instance of the <see cref="RequestHandler{TRequest}"/> class. /// </summary> /// <param name="controlBusSender">The control bus command processor, to post over</param> /// <param name="monitorConfiguration"></param> public MonitorHandler(IAmAControlBusSender controlBusSender, MonitorConfiguration monitorConfiguration) : this(controlBusSender, LogProvider.For <MonitorHandler <T> >(), monitorConfiguration) { }
public static void Init(MonitorConfiguration conf, IList<LogWriter> writers) { lock (instanceLock) { if (instance == null) { instance = new Logger(conf); instance.AddWriters(writers); } } }
static void Main(string[] args) { var random = new Random(); MonitorConfiguration config = ConfigurationReader.Read(GetConfigPath()); MonitorWrapper wrapper = MonitorWrapper.Instance; wrapper.ApplyConfig(config); wrapper.Start(); DistributedMonitor monitor = wrapper.CreateMonitorIfNotExists(1); // Przygotowanie zmiennej warunkowej monitor.Acquire(); var cv = monitor.CreateConditionalVariableIfNotExists(1); if (cv.Value == null) { cv.Value = 0; } monitor.Release(); if (wrapper.ID == 0 || wrapper.ID == 1 || wrapper.ID == 2) { while (true) { //READERS monitor.Acquire(); while (((int)cv.Value) < 0) { Console.WriteLine($"Wait {wrapper.ID} - pisarz w środku"); cv.Wait(); } cv.Value = (int)cv.Value + 1; monitor.Release(); Console.WriteLine($"Czytam {wrapper.ID}"); Thread.Sleep(random.Next(1000, 3000)); Console.WriteLine($"Skończyłem {wrapper.ID}"); monitor.Acquire(); cv.Value = (int)cv.Value - 1; if ((int)cv.Value == 0) { cv.SignalAll(); } monitor.Release(); Console.WriteLine($"Wyszedłem i czekam {wrapper.ID}"); Thread.Sleep(random.Next(3000, 5000)); } } else { //WRITERS while (true) { monitor.Acquire(); while (((int)cv.Value) != 0) { Console.WriteLine($"Wait {wrapper.ID} - ktoś w środku"); cv.Wait(); } cv.Value = -1; monitor.Release(); Console.WriteLine($"Piszę {wrapper.ID}"); Thread.Sleep(random.Next(1000, 3000)); Console.WriteLine($"Skończyłem {wrapper.ID}"); monitor.Acquire(); cv.Value = 0; cv.SignalAll(); monitor.Release(); Console.WriteLine($"Wyszedłem i czekam {wrapper.ID}"); Thread.Sleep(random.Next(3000, 5000)); } } }
private Logger(MonitorConfiguration conf) { Enum.TryParse<LogLevel>(conf.LogLevel, out this.logLevel); }
private void RunMonitoringTask(MonitorConfiguration conf) { Logger.Info("Start monitoring task"); DateTime start = DateTime.Now; MonitoringTask task = MonitoringTask.CreateInstance(conf); task.Run(); Logger.Info("Monitoring task finished"); TimeSpan elapsed = DateTime.Now.Subtract(start); //Substract elapsed time to get the task running exaclty aliging to refresh rate. long interval = Math.Max(conf.RefreshRate, MIN_REFRESH_RATE) * 1000; long timeToWait = interval - (long)elapsed.TotalMilliseconds % interval; //Trigger next task timer.Change(timeToWait, Timeout.Infinite); }
public void TestRotateLog() { var tmpFolder = System.Environment.GetFolderPath(System.Environment.SpecialFolder.CommonApplicationData) + @"\" + Guid.NewGuid().ToString(); Console.WriteLine(tmpFolder); Directory.CreateDirectory(tmpFolder); var conf = new MonitorConfiguration() { LogLevel = "Info", LogFilePath = tmpFolder + @"\test.log", LogFileSize = 1, MaxLogRetention = 2 }; var logWriter = new FileLogWriter(conf); String[] logContent = new String[4] { "Test 0","Test 1","Test 2","Test 3", }; //echo "Test 0" > test.log logWriter.Write(LogLevel.Info, logContent[0]); //mv test.log test.log.0 //echo "Test 1" > test.log logWriter.Write(LogLevel.Info, logContent[1]); Assert.IsTrue(File.Exists(conf.LogFilePath)); String log = File.ReadAllText(conf.LogFilePath); Assert.IsTrue(log.Contains(logContent[1])); Assert.IsTrue(File.Exists(conf.LogFilePath + @".0")); log = File.ReadAllText(conf.LogFilePath + @".0"); Assert.IsTrue(log.Contains(logContent[0])); //mv test.log.0 test.log.1 //mv test.log test.log.0 //echo "Test 2" > test.log logWriter.Write(LogLevel.Info, logContent[2]); //rm test.log.1 //mv test.log.0 test.log.1 //mv test.log test.log.0 //echo "Test 3" test.log logWriter.Write(LogLevel.Info, logContent[3]); Assert.IsTrue(File.Exists(conf.LogFilePath + @".0")); Assert.IsTrue(File.Exists(conf.LogFilePath + @".1")); Assert.IsFalse(File.Exists(conf.LogFilePath + @".2")); log = File.ReadAllText(conf.LogFilePath); Assert.IsTrue(log.Contains(logContent[3])); log = File.ReadAllText(conf.LogFilePath + @".1"); Assert.IsTrue(log.Contains(logContent[1])); Directory.Delete(tmpFolder, true); }
public ShimEventLogWriter(MonitorConfiguration conf) : base(conf) { }
public void TestZeroLogWriter() { var conf = new MonitorConfiguration() { LogLevel = "Infoasdfasdf" }; Logger.Init(conf, new LogWriter[0]); Logger.Info("Test"); }
public void TestWriteToLogFile() { var tmpFolder = System.Environment.GetFolderPath(System.Environment.SpecialFolder.CommonApplicationData) + @"\" + Guid.NewGuid().ToString(); var conf = new MonitorConfiguration() { LogLevel = "Info", LogFilePath = tmpFolder + @"\test.log" }; var logWriter = new FileLogWriter(conf); String logContent = Guid.NewGuid().ToString(); logWriter.Write(LogLevel.Info, logContent); Assert.IsTrue(File.Exists(conf.LogFilePath)); String log = File.ReadAllText(conf.LogFilePath); Assert.IsTrue(log.Contains(logContent)); Directory.Delete(tmpFolder, true); }
/// <summary> /// Initializes a new instance of the <see cref="RequestHandler{TRequest}"/> class. /// Use this instance if you need to inject a logger, for example for testing /// </summary> /// <param name="controlBusSender">The control bus command processor, to post over</param> /// <param name="logger">The logger</param> /// <param name="monitorConfiguration"></param> public MonitorHandler(IAmAControlBusSender controlBusSender, ILog logger, MonitorConfiguration monitorConfiguration) : base(logger) { _controlBusSender = controlBusSender; _isMonitoringEnabled = monitorConfiguration.IsMonitoringEnabled; _instanceName = monitorConfiguration.InstanceName; }
public static void Init(MonitorConfiguration conf) { Init(conf, new LogWriter[] { new FileLogWriter(conf), new EventLogWriter(conf) }); }