public Bot(DiscordSocketConfig config, ICommandHandler handler, IAsyncLogger logger) { this.client = new DiscordSocketClient(config); this.handler = handler; this.logger = logger; Init(); }
/// <summary> /// Initializes a new instance of the <see cref="WebsOperation" /> class. /// </summary> /// <param name="logger">The logger.</param> /// <param name="retryCount">The retry count.</param> /// <param name="delay">The delay.</param> /// <param name="userAgent">The user agent.</param> public WebsOperation(IAsyncLogger logger, int retryCount, int delay, string userAgent) { ModernWebsList = new List <ModernWeb>(); Logger = logger; RetryCount = int.Parse(ConfigurationManager.AppSettings[Constants.AppSettings.RetryCountKey]); Delay = int.Parse(ConfigurationManager.AppSettings[Constants.AppSettings.DelayKey]); UserAgent = ConfigurationManager.AppSettings[Constants.AppSettings.UserAgentKey]; }
/// <summary> /// Defines the entry point of the application. /// </summary> /// <param name="args">The arguments.</param> static void Main(string[] args) { IAsyncLogger logger = O365GroupsFactory.GetLogger(new string[] { Constants.AppSettings.LoggerInstanceKey }) as IAsyncLogger; var siteMapFileName = ConfigurationManager.AppSettings[Constants.AppSettings.SiteMapKey]; var siteMapSheetName = ConfigurationManager.AppSettings[Constants.AppSettings.SiteMapSheetKey]; var userMappingFileName = ConfigurationManager.AppSettings[Constants.AppSettings.UserMappingKey]; var userMappingSheetName = ConfigurationManager.AppSettings[Constants.AppSettings.UserMappingSheetKey]; var retryCount = int.Parse(ConfigurationManager.AppSettings[Constants.AppSettings.RetryCountKey]); var delay = int.Parse(ConfigurationManager.AppSettings[Constants.AppSettings.DelayKey]); var userAgent = ConfigurationManager.AppSettings[Constants.AppSettings.UserAgentKey]; logger.Log("Reading Files..."); var csvOperation = new CSVOperations(); var siteMapDetails = csvOperation.ReadFile(Constants.SiteMapSheet, siteMapFileName, siteMapSheetName).Cast <SiteMapReport>().ToList(); SecurityPrincipal.UserMappingList = csvOperation.ReadFile(Constants.UserMappingSheet, userMappingFileName, userMappingSheetName).Cast <UserMappingReport>().ToList(); if (siteMapDetails != null) { SecureString sourcePassword = GetSecureString(Constants.PasswordMessageSource); SecureString targetPassword = GetSecureString(Constants.PasswordMessageTarget); Object lockObj = new Object(); //Stopwatch watch = new Stopwatch(); //watch.Start(); List <ModernWeb> websList = new List <ModernWeb>(); logger.Log("Processing read sites from CSV"); foreach (var siteMap in siteMapDetails) { logger.Log("Reading " + siteMap.SourceSiteUrl); var modernWeb = new ModernWeb { SourceSiteUrl = siteMap.SourceSiteUrl, TargetSiteUrl = siteMap.TargetSiteUrl, SourceUserName = siteMap.SourceUser, TargetUserName = siteMap.TargetUser, SourcePassword = sourcePassword, TargetPassword = targetPassword }; WebsOperation websOperation = new WebsOperation(logger, retryCount, delay, userAgent); websOperation.ModernWeb = modernWeb; websOperation.MigrateWebs(); } //watch.Stop(); logger.Log("Processing complete"); Console.WriteLine("Processing Complete"); //Console.WriteLine("Elapsed Time " + watch.Elapsed.ToString()); } Console.ReadLine(); }
private static void LogError(IAsyncLogger logger, int iterationCount = 10) { Check.ArgumentIsNull(logger, nameof(logger)); Check.Argument(iterationCount > 0, "iterationCount > 0"); for (var i = 0; i < iterationCount; i++) { logger.Log("Error", $"Error {i} from LoggerProcessor"); Thread.Sleep(1); } }
private static void LogError(IAsyncLogger logger, object thread) { Check.ArgumentIsNull(logger, nameof(logger)); Check.ArgumentIsNull(thread, nameof(thread)); for (var i = 0; i < 10; i++) { logger.Log("Error", $"Error {i} from thread {thread}", new { thread, iteration = i }); Console.WriteLine($"Thread - {thread}, iteration - {i}"); Thread.Sleep(1); } }
public async Task Setup() { var configuration = new ConfigurationBuilder() .AddJsonFile("appsettings.json", true, true) .Build(); configuration.GetSection("OskSettings").Bind(_oskSettings); _mongoUtils = new MongoUtils(_oskSettings); _addStatisticsGrain = new MongoManageStatisticsGrain <TestModel>(_mongoUtils); _getStatisticsGrain = new MongoGetStatisticsGrain <TestModel>(_mongoUtils, new NLogLogger()); _grainsContext = new GenericGrainsContext(); _logger = new NLogLogger(); _executiveGrain = new GenericExecutiveGrain(new MemoryAssemblyMembersCache(new MemoryAssemblyCache()), _logger); //var clt = new ClientStartup(); //var client = await clt.StartClientWithRetries(); //_grainsExecutivePool = new GrainsExecutivePool(client, 10); await FillData(); }
/// <summary> /// Creates the proper. /// </summary> /// <param name="rollbarConfig">The rollbar configuration.</param> /// <param name="rollbarBlockingLoggingTimeout">The rollbar blocking logging timeout.</param> /// <param name="rollbarAsyncLogger">The rollbar asynchronous logger.</param> /// <param name="rollbarLogger">The rollbar logger.</param> public static void CreateProper( IRollbarConfig rollbarConfig, TimeSpan?rollbarBlockingLoggingTimeout, out IAsyncLogger rollbarAsyncLogger, out ILogger rollbarLogger ) { IRollbar rollbar = RollbarFactory.CreateNew().Configure(rollbarConfig); if (rollbarBlockingLoggingTimeout.HasValue) { rollbarLogger = rollbar.AsBlockingLogger(rollbarBlockingLoggingTimeout.Value); rollbarAsyncLogger = null; } else { rollbarLogger = null; rollbarAsyncLogger = rollbar; } }
public MongoGetStatisticsGrain(MongoUtils mongoUtils, IAsyncLogger logger) { _mongoUtils = mongoUtils; _logger = logger; }
public StatisticsClient(IClusterClient client, IAsyncLogger logger) { _client = client; _logger = logger; }
/// <summary> /// Initializes a new instance of the <see cref="SecurityPrincipal" /> class. /// </summary> /// <param name="logger">The logger.</param> /// <param name="retryCount">The retry count.</param> /// <param name="delay">The delay.</param> public SecurityPrincipal(IAsyncLogger logger, int retryCount, int delay) { Logger = logger; RetryCount = retryCount; Delay = delay; }
public LogMiddleware(RequestDelegate nextMiddleware, IAsyncLogger asyncLogger) { _nextMiddleware = nextMiddleware; _asyncLogger = asyncLogger ?? throw new ArgumentNullException(typeof(IAsyncLogger).FullName); }
public GenericExecutiveGrain(IAssemblyMembersCache assemblyMembersCache, IAsyncLogger logger) { _assemblyMembersCache = assemblyMembersCache; _logger = logger; }
/// <summary> /// Makes a <see cref="IAsyncLogger"/> into a <see cref="ISyncLogger"/> by adding a memory queue. /// </summary> public static ISyncLogger AsQueuedSyncLogger(this IAsyncLogger value) => new QueueToAsyncLogger(value);
public TarantoolGetStatisticsGrain(TarantoolUtils mongoUtils, IAsyncLogger logger) { _tarantoolUtils = mongoUtils; _logger = logger; }
/// <summary> /// Initializes a new instance of the <see cref="ModernPage"/> class. /// </summary> /// <param name="logger">The logger.</param> /// <param name="retryCount">The retry count.</param> /// <param name="delay">The delay.</param> public ModernPage(IAsyncLogger logger, int retryCount, int delay) { Logger = logger; RetryCount = retryCount; Delay = delay; }
/// <summary> /// Reports to Rollbar. /// </summary> /// <param name="logger">The logger.</param> /// <param name="rollbarData">The Rollbar data.</param> private static void ReportToRollbar(IAsyncLogger logger, DTOs.Data rollbarData) { logger.Log(rollbarData); }
public WebPartOperation(IAsyncLogger logger, int retryCount, int delay) { Logger = logger; RetryCount = retryCount; Delay = delay; }
/// <summary> /// Initializes a new instance of the <see cref="WikiPage"/> class. /// </summary> /// <param name="logger">The logger.</param> /// <param name="retryCount">The retry count.</param> /// <param name="delay">The delay.</param> public WikiPage(IAsyncLogger logger, int retryCount, int delay) : base(logger, retryCount, delay) { Logger = logger; RetryCount = retryCount; Delay = delay; }
public CsvParser(ILineSource lineSource, IAsyncLogger logger) { LineSource = lineSource ?? throw new ArgumentNullException(nameof(lineSource)); Logger = logger ?? throw new ArgumentNullException(nameof(logger)); LineSource.ErrorOccured += LineSource_ErrorOccured; }
private void EvaluateLogMethod(ClassificationDeclaration classificationDeclaration) { RollbarConfig loggerConfig = ProvideRollbarConfig(); object payload = null; switch (classificationDeclaration.PayloadType) { case PayloadType.Message: { payload = ProvideObjectToLog(classificationDeclaration); } break; case PayloadType.Exception: { payload = ProvideObjectToLog(classificationDeclaration); } break; default: break; } Assert.IsNotNull(payload); // Let's give things change to stabilize: //Thread.Sleep(TimeSpan.FromSeconds(2)); using (var rollbar = RollbarFactory.CreateNew().Configure(loggerConfig)) { for (int i = 0; i < Constants.TotalMeasurementSamples; i++) { switch (classificationDeclaration.MethodVariant) { case MethodVariant.Async: { IAsyncLogger logger = rollbar; using (PerformanceUtil.GetPerformanceTimer(classificationDeclaration)) { logger.Log(ErrorLevel.Warning, payload); } break; } case MethodVariant.AsyncWaited: { IAsyncLogger logger = rollbar; using (PerformanceUtil.GetPerformanceTimer(classificationDeclaration)) { logger.Log(ErrorLevel.Warning, payload).Wait(); } break; } case MethodVariant.Blocking: { // NOTE: for blocking call we want to eliminate effect of // the max reporting rate restriction, so that the wait time // that is a result of the rate limit is not counted against // the blocking call: BlockUntilRollbarQueuesAreEmpty(); Thread.Sleep(TimeSpan.FromSeconds(60 / rollbar.Config.MaxReportsPerMinute)); ILogger logger = rollbar.AsBlockingLogger(Constants.RollbarBlockingTimeout); using (PerformanceUtil.GetPerformanceTimer(classificationDeclaration)) { logger.Log(ErrorLevel.Critical, payload); } break; } default: // nothing to do... break; } } //BlockUntilRollbarQueuesAreEmpty(); //Thread.Sleep(TimeSpan.FromMilliseconds(250)); //if (classificationDeclaration.MethodVariant == MethodVariant.Async) //{ // // NOTE: for async call we want to make sure the logger's instance is not // // disposed until all the buffered payloads delivered to the Rollbar API. // // This delay ios needed until issue #197 is resolved... // BlockUntilRollbarQueuesAreEmpty(); //} } }
public AsyncExceptionFilter(IAsyncLogger asyncLogger) { _asyncLogger = asyncLogger ?? throw new ArgumentNullException(typeof(IAsyncLogger).FullName); }
public AsyncCommandHandler(IAsyncLogger logger) { this.logger = logger; Init(); }
static void Main(string[] args) { IAsyncLogger logger = O365GroupsFactory.GetLogger(new string[] { Constants.AppSettings.LoggerInstanceKey }) as IAsyncLogger; var siteMapFileName = ConfigurationManager.AppSettings[Constants.AppSettings.UserExportSiteMapKey]; var siteMapSheetName = ConfigurationManager.AppSettings[Constants.AppSettings.SiteMapSheetKey]; var retryCount = int.Parse(ConfigurationManager.AppSettings[Constants.AppSettings.RetryCountKey]); var delay = int.Parse(ConfigurationManager.AppSettings[Constants.AppSettings.DelayKey]); var userAgent = ConfigurationManager.AppSettings[Constants.AppSettings.UserAgentKey]; List <string> completedSitesList = new List <string>(); List <string> erroredSitesList = new List <string>(); ConsoleOperations.WriteToConsole("Reading Files...", ConsoleColor.White); var csvOperation = new CSVOperations(); var siteMapDetails = csvOperation.ReadFile(Constants.AppSettings.UserExportSiteMapKey, siteMapFileName, siteMapSheetName).Cast <UserExportSiteMapReport>().ToList(); if (siteMapDetails != null) { SecureString sourcePassword = GetSecureString(Constants.PasswordMessageSource); //Stopwatch watch = new Stopwatch(); //watch.Start(); List <WebSite> websList = new List <WebSite>(); ConsoleOperations.WriteToConsole("Processing read sites from CSV", ConsoleColor.White); foreach (var siteMap in siteMapDetails) { logger.Log("Reading " + siteMap.SourceSiteUrl); var website = new WebSite { SourceSiteUrl = siteMap.SourceSiteUrl.Trim(), SourceUserName = siteMap.SourceUser.Trim(), SourcePassword = sourcePassword, Delay = delay, RetryCount = retryCount, UserAgent = userAgent }; websList.Add(website); } try { WebsUtility websOperation = new WebsUtility(retryCount, delay, userAgent); websOperation.WebSiteList = websList; (completedSitesList, erroredSitesList) = websOperation.ExportUsersList(); } catch (Exception ex) { ConsoleOperations.WriteToConsole("Error ocurred: " + ex.Message, ConsoleColor.Red); } //watch.Stop(); logger.Log("Processing complete"); ConsoleOperations.WriteToConsole($"Processing Complete; Total successful site count: {completedSitesList.Count}. The completed list is as follows:", ConsoleColor.Green); completedSitesList.ForEach(site => { ConsoleOperations.WriteToConsole(site, ConsoleColor.DarkCyan); }); ConsoleOperations.WriteToConsole("Total Errored sites: " + erroredSitesList.Count, ConsoleColor.Red); if (erroredSitesList.Count > 0) { ConsoleOperations.WriteToConsole("List: ", ConsoleColor.Red); erroredSitesList.ForEach(site => { ConsoleOperations.WriteToConsole(site, ConsoleColor.Red); }); } Console.ReadLine(); //Console.WriteLine("Elapsed Time " + watch.Elapsed.ToString()); } }