public static IDependencyResolver Create() { var result = new MyDependencyResolver(); #if DEBUG var log = new LogToConsole(); result.IoC.BindAzureReposInMem(); result.IoC.BinMockAzureDebug(); #else var log = new LogToTable(new AzureTableStorage <LogEntity>(Settings.ConnectionString, "LogApi", null)); result.IoC.BindAzureRepositories(Settings.ConnectionString, Settings.ConnectionString, log); result.IoC.BindMockAzureRepositories(Settings.ConnectionString, log); #endif result.IoC.BindLykkeWalletServices(); result.IoC.BindMockServices(); log.WriteInfo("ApiDependencies", "Create", "Create", "Create"); GetIdentity = ctr => { var ctx = ctr as ApiController; return(ctx?.User.Identity.Name); }; return(result); }
private static ILog CreateLog(IServiceCollection services, ApplicationSettings settings) { var appSettings = settings.MarketProfileService; LykkeLogToAzureStorage logToAzureStorage = null; var logToConsole = new LogToConsole(); var logAggregate = new LogAggregate(); logAggregate.AddLogger(logToConsole); if (!string.IsNullOrEmpty(appSettings.Db.LogsConnectionString) && !(appSettings.Db.LogsConnectionString.StartsWith("${") && appSettings.Db.LogsConnectionString.EndsWith("}"))) { logToAzureStorage = new LykkeLogToAzureStorage("Lykke.Service.MarketProfile", new AzureTableStorage <LogEntity>( appSettings.Db.LogsConnectionString, "MarketProfileService", logToConsole)); logAggregate.AddLogger(logToAzureStorage); } var log = logAggregate.CreateLogger(); var slackService = services.UseSlackNotificationsSenderViaAzureQueue(new AzureQueueSettings { ConnectionString = settings.SlackNotifications.AzureQueue.ConnectionString, QueueName = settings.SlackNotifications.AzureQueue.QueueName }, log); logToAzureStorage?.SetSlackNotification(slackService); return(log); }
private static ILog CreateLog(IConfiguration configuration, IServiceCollection services, IReloadingManager <AppSettings> settings) { var logName = $"{nameof(OrderBookService)}Log"; var consoleLogger = new LogToConsole(); var aggregateLogger = new AggregateLogger(); aggregateLogger.AddLog(consoleLogger); if (settings.CurrentValue.OrderBookService.UseSerilog) { aggregateLogger.AddLog(new SerilogLogger(typeof(Startup).Assembly, configuration)); } else if (settings.CurrentValue.OrderBookService.Db.StorageMode == StorageMode.SqlServer) { aggregateLogger.AddLog(new LogToSql(new SqlLogRepository(logName, settings.CurrentValue.OrderBookService.Db.LogsConnString))); } else if (settings.CurrentValue.OrderBookService.Db.StorageMode == StorageMode.Azure) { aggregateLogger.AddLog(services.UseLogToAzureStorage(settings.Nested(s => s.OrderBookService.Db.LogsConnString), null, logName, consoleLogger)); } LogLocator.Log = aggregateLogger; return(aggregateLogger); }
public (IContainer resolver, ILog logToConsole) GetResolver(IReloadingManager <AppSettings> appSettings) { ContainerBuilder containerBuilder = new ContainerBuilder(); IServiceCollection collection = new Microsoft.Extensions.DependencyInjection.ServiceCollection(); containerBuilder.RegisterInstance(appSettings); containerBuilder.RegisterInstance <IBaseSettings>(appSettings.CurrentValue.EthereumCore); containerBuilder.RegisterInstance <ISlackNotificationSettings>(appSettings.CurrentValue.SlackNotifications); containerBuilder.RegisterInstance(appSettings.Nested(x => x.EthereumCore)); containerBuilder.RegisterInstance(appSettings.CurrentValue); var consoleLogger = new LogToConsole(); collection.AddSingleton <ILog>(consoleLogger); RegisterReposExt.RegisterAzureQueues(containerBuilder, appSettings.Nested(x => x.EthereumCore.Db.DataConnString), appSettings.Nested(x => x.SlackNotifications)); RegisterReposExt.RegisterAzureStorages(containerBuilder, appSettings.Nested(x => x.EthereumCore), appSettings.Nested(x => x.SlackNotifications), consoleLogger); RegisterRabbitQueueEx.RegisterRabbitQueue(collection, appSettings.Nested(x => x.EthereumCore.RabbitMq), appSettings.Nested(x => x.EthereumCore.Db.DataConnString), consoleLogger); RegisterDependency.RegisterServices(collection); RegisterDependency.RegisterServices(containerBuilder); containerBuilder.Populate(collection); containerBuilder.RegisterInstance <ILog>(consoleLogger); var resolver = containerBuilder.Build(); resolver.ActivateRequestInterceptor(); return(resolver, consoleLogger); }
public GdaxWssApiClientTests() { _configuration = GdaxHelpers.GetGdaxConfiguration(); _logger = new LogToConsole(); _api = new GdaxWebSocketApi(_logger, _configuration.ApiKey, _configuration.ApiSecret, _configuration.PassPhrase, _configuration.WssEndpointUrl); }
public void ConfigureServices(IServiceCollection services) #endif { // Add MVC services.AddMvc(); // Create a logger var logger = new LogToConsole(); // Configure API Authentication var apiAzureConfig = Configuration .GetSection("LykkeApiAuth") .Get <ApiAuthAzureConfig>(); services.AddLykkeApiAuthAzure(apiAzureConfig, logger); // Configure services/repositories services.AddLykkeTemplateAzureRepositories(conf => { conf.ConnectionString = Configuration .GetValue <string>("LykkeTempApi:ConnectionString"); conf.Logger = logger; }); #if (autofac) // Configure AutoFac var builder = new ContainerBuilder(); builder.Populate(services); ApplicationContainer = builder.Build(); return(new AutofacServiceProvider(ApplicationContainer)); #endif }
public ILogger GetLogger(ObjectType objectType) { ILogger logger = null; switch (objectType) { case ObjectType.CONSOLE: logger = new LogToConsole(); break; case ObjectType.FILE: logger = new LogToFile(); break; case ObjectType.DATABASE: logger = new LogToDB(); break; default: logger = new LogToFile(); break; } return(logger); }
public FixClient(string targetCompId = Const.TargetCompId, string senderCompId = Const.SenderCompId, string uri = Const.Uri, int port = Const.Port) { var s = new SessionSetting { TargetCompID = targetCompId, SenderCompID = senderCompId, FixConfiguration = new[] { "[DEFAULT]", "ResetOnLogon=Y", "FileStorePath=client", "ConnectionType=initiator", "ReconnectInterval=60", "BeginString=FIX.4.4", @"DataDictionary=ClientFIX44.xml", "SSLEnable=N", @"SSLProtocols=Tls", "SSLValidateCertificates=N", $"SocketConnectPort={port}", "StartTime=00:00:00", "EndTime=00:00:00", "HeartBtInt=10", "LogonTimeout=120", $"SocketConnectHost={uri}", "[SESSION]", } }; _log = new LogToConsole(); var settings = new SessionSettings(s.GetFixConfigAsReader()); var storeFactory = new MemoryStoreFactory(); var logFactory = new LykkeLogFactory(_log, false, false, false); _socketInitiator = new SocketInitiator(this, storeFactory, settings, logFactory); }
private static void SetupLoggers(IServiceCollection services, IReloadingManager <MtBackendSettings> mtSettings, IReloadingManager <MarginSettings> settings) { var consoleLogger = new LogToConsole(); var azureQueue = new AzureQueueSettings { ConnectionString = mtSettings.CurrentValue.SlackNotifications.AzureQueue.ConnectionString, QueueName = mtSettings.CurrentValue.SlackNotifications.AzureQueue.QueueName }; var commonSlackService = services.UseSlackNotificationsSenderViaAzureQueue(azureQueue, consoleLogger); var slackService = new MtSlackNotificationsSender(commonSlackService, "MT Backend", settings.CurrentValue.Env); services.AddSingleton <ISlackNotificationsSender>(slackService); services.AddSingleton <IMtSlackNotificationsSender>(slackService); // Order of logs registration is important - UseLogToAzureStorage() registers ILog in container. // Last registration wins. LogLocator.RequestsLog = services.UseLogToAzureStorage(settings.Nested(s => s.Db.LogsConnString), slackService, "MarginTradingBackendRequestsLog", consoleLogger); LogLocator.CommonLog = services.UseLogToAzureStorage(settings.Nested(s => s.Db.LogsConnString), slackService, "MarginTradingBackendLog", consoleLogger); }
private static ILog CreateLogWithSlack(IServiceCollection services, IReloadingManager <AppSettings> settings) { var consoleLogger = new LogToConsole(); var aggregateLogger = new AggregateLogger(); aggregateLogger.AddLog(consoleLogger); // Creating slack notification service, which logs own azure queue processing messages to aggregate log var slackService = services.UseSlackNotificationsSenderViaAzureQueue(new AzureQueueIntegration.AzureQueueSettings { ConnectionString = settings.CurrentValue.SlackNotifications.AzureQueue.ConnectionString, QueueName = settings.CurrentValue.SlackNotifications.AzureQueue.QueueName }, aggregateLogger); var dbLogConnectionStringManager = settings.Nested(x => x.SlackNotificationsJobSettings.LogsConnectionString); var dbLogConnectionString = dbLogConnectionStringManager.CurrentValue; // Creating azure storage logger, which logs own messages to concole log if (!string.IsNullOrEmpty(dbLogConnectionString) && !(dbLogConnectionString.StartsWith("${") && dbLogConnectionString.EndsWith("}"))) { var persistenceManager = new LykkeLogToAzureStoragePersistenceManager( AzureTableStorage <LogEntity> .Create(dbLogConnectionStringManager, "SlackNotificationsJobLogs", consoleLogger), consoleLogger); var slackNotificationsManager = new LykkeLogToAzureSlackNotificationsManager(slackService, consoleLogger); var azureStorageLogger = new LykkeLogToAzureStorage(persistenceManager, slackNotificationsManager, consoleLogger); azureStorageLogger.Start(); aggregateLogger.AddLog(azureStorageLogger); } return(aggregateLogger); }
protected virtual ILog CreateLogWithSlack(IServiceCollection services, IReloadingManager <TApplicationSettings> settings, bool isLive) { var logToConsole = new LogToConsole(); var aggregateLogger = new AggregateLogger(); aggregateLogger.AddLog(logToConsole); var commonSlackService = services.UseSlackNotificationsSenderViaAzureQueue(settings.CurrentValue.SlackNotifications.AzureQueue, aggregateLogger); var slackService = new MtSlackNotificationsSender(commonSlackService, ApplicationName, Configuration.ServerType()); services.AddSingleton <ISlackNotificationsSender>(slackService); // Creating azure storage logger, which logs own messages to concole log var dbLogConnectionString = settings.CurrentValue.MtBrokersLogs?.DbConnString; if (!string.IsNullOrEmpty(dbLogConnectionString) && !(dbLogConnectionString.StartsWith("${") && dbLogConnectionString.EndsWith("}"))) { var logToAzureStorage = services.UseLogToAzureStorage( settings.Nested(s => s.MtBrokersLogs.DbConnString), slackService, ApplicationName + Configuration.ServerType() + "Log", aggregateLogger); aggregateLogger.AddLog(logToAzureStorage); } return(aggregateLogger); }
private static ILog CreateLogWithSlack(IServiceCollection services, AppSettings settings) { LykkeLogToAzureStorage logToAzureStorage = null; var logToConsole = new LogToConsole(); var logAggregate = new LogAggregate(); logAggregate.AddLogger(logToConsole); var dbLogConnectionString = settings.LykkeServiceService.Db.LogsConnString; // Creating azure storage logger, which logs own messages to concole log if (!string.IsNullOrEmpty(dbLogConnectionString) && !(dbLogConnectionString.StartsWith("${") && dbLogConnectionString.EndsWith("}"))) { logToAzureStorage = new LykkeLogToAzureStorage("Lykke.Service.LykkeService", new AzureTableStorage <LogEntity>( dbLogConnectionString, "LykkeServiceLog", logToConsole)); logAggregate.AddLogger(logToAzureStorage); } // Creating aggregate log, which logs to console and to azure storage, if last one specified var log = logAggregate.CreateLogger(); // Creating slack notification service, which logs own azure queue processing messages to aggregate log var slackService = services.UseSlackNotificationsSenderViaAzureQueue(new AzureQueueIntegration.AzureQueueSettings { ConnectionString = settings.SlackNotifications.AzureQueue.ConnectionString, QueueName = settings.SlackNotifications.AzureQueue.QueueName }, log); // Finally, setting slack notification for azure storage log, which will forward necessary message to slack service logToAzureStorage?.SetSlackNotification(slackService); return(log); }
public static IDependencyResolver CreateDepencencyResolver() { var dr = new MyDependencyResolver(); var log = new LogToConsole(); dr.IoC.Register <ILog>(log); #if DEBUG AzureRepoBinder.BindAzureReposInMem(dr.IoC); #else AzureRepoBinder.BindAzureRepositories(dr.IoC, Settings.ConnectionString, log); #endif SrvBinder.BindTraderPortalServices(dr.IoC); BindWebSiteSerives(dr.IoC); BalanceAccess = dr.IoC.GetObject <SrvBalanceAccess>(); SrvOrdersRegistrator = dr.IoC.GetObject <SrvOrdersRegistrator>(); SrvOrdersExecutor = dr.IoC.GetObject <SrvOrdersExecutor>(); SrvLimitOrderBookGenerator = dr.IoC.GetObject <SrvLimitOrderBookGenerator>(); AssetPairsDictionary = dr.IoC.GetObject <IAssetPairsDictionary>(); SrvBinder.StartTraderPortalServices(dr.IoC); SrvOrdersExecutor.RegisterBalanceChange(LkHub.RefreshBalance); return(dr); }
private static ILog CreateLogWithSlack(IServiceCollection services, IReloadingManager <AppSettings> settings) { var consoleLogger = new LogToConsole(); var aggregateLogger = new AggregateLogger(); aggregateLogger.AddLog(consoleLogger); var dbLogConnectionStringManager = settings.Nested(x => x.DynamicJob.Db.LogsConnString); var dbLogConnectionString = dbLogConnectionStringManager.CurrentValue; if (string.IsNullOrEmpty(dbLogConnectionString)) { consoleLogger.WriteWarningAsync(nameof(Startup), nameof(CreateLogWithSlack), "Table loggger is not inited").Wait(); return(aggregateLogger); } if (dbLogConnectionString.StartsWith("${") && dbLogConnectionString.EndsWith("}")) { throw new InvalidOperationException($"LogsConnString {dbLogConnectionString} is not filled in settings"); } var persistenceManager = new LykkeLogToAzureStoragePersistenceManager( AzureTableStorage <LogEntity> .Create(dbLogConnectionStringManager, "DynamicJobLog", consoleLogger), consoleLogger); // Creating slack notification service, which logs own azure queue processing messages to aggregate log var slackService = services.UseSlackNotificationsSenderViaAzureQueue(new AzureQueueIntegration.AzureQueueSettings { ConnectionString = settings.CurrentValue.SlackNotifications.AzureQueue.ConnectionString, QueueName = settings.CurrentValue.SlackNotifications.AzureQueue.QueueName }, aggregateLogger); var slackNotificationsManager = new LykkeLogToAzureSlackNotificationsManager(slackService, consoleLogger); // Creating azure storage logger, which logs own messages to concole log var azureStorageLogger = new LykkeLogToAzureStorage( persistenceManager, slackNotificationsManager, consoleLogger); azureStorageLogger.Start(); aggregateLogger.AddLog(azureStorageLogger); aggregateLogger.AddLog(LykkeLogToSlack.Create ( slackService, "BlockChainIntegration", LogLevel.All )); aggregateLogger.AddLog(LykkeLogToSlack.Create ( slackService, "BlockChainIntegrationImportantMessages", LogLevel.All ^ LogLevel.Info )); return(aggregateLogger); }
private static ILog CreateLog( IConfiguration configuration, IReloadingManager <AppSettings> settings, IServiceCollection services, CorrelationContextAccessor correlationContextAccessor) { var aggregateLogger = new AggregateLogger(); var consoleLogger = new LogToConsole(); aggregateLogger.AddLog(consoleLogger); if (settings.CurrentValue.MarginTradingAccountManagement.UseSerilog) { aggregateLogger.AddLog(new SerilogLogger(typeof(Startup).Assembly, configuration, new List <ILogEventEnricher> { new CorrelationLogEventEnricher("CorrelationId", correlationContextAccessor) })); } else if (settings.CurrentValue.MarginTradingAccountManagement.Db.StorageMode == StorageMode.SqlServer.ToString()) { var sqlLogger = new LogToSql(new SqlLogRepository("AccountManagementLog", settings.CurrentValue.MarginTradingAccountManagement.Db.LogsConnString)); aggregateLogger.AddLog(sqlLogger); } else if (settings.CurrentValue.MarginTradingAccountManagement.Db.StorageMode == StorageMode.Azure.ToString()) { var dbLogConnectionStringManager = settings.Nested(x => x.MarginTradingAccountManagement.Db.LogsConnString); var dbLogConnectionString = dbLogConnectionStringManager.CurrentValue; if (string.IsNullOrEmpty(dbLogConnectionString)) { consoleLogger.WriteWarningAsync(nameof(Startup), nameof(CreateLog), "Table logger is not initialized").Wait(); return(aggregateLogger); } if (dbLogConnectionString.StartsWith("${") && dbLogConnectionString.EndsWith("}")) { throw new InvalidOperationException($"LogsConnString {dbLogConnectionString} is not filled in settings"); } var persistenceManager = new LykkeLogToAzureStoragePersistenceManager( AzureTableStorage <Lykke.Logs.LogEntity> .Create(dbLogConnectionStringManager, "AccountManagementLog", consoleLogger), consoleLogger); // Creating azure storage logger, which logs own messages to console log var azureStorageLogger = new LykkeLogToAzureStorage(persistenceManager, null, consoleLogger); azureStorageLogger.Start(); aggregateLogger.AddLog(azureStorageLogger); } LogLocator.Log = aggregateLogger; return(aggregateLogger); }
private void Setup(RabbitMqSubscriptionSettings settings) { var logger = new LogToConsole(); _connector = new RabbitMqSubscriber <T>(settings, new DefaultErrorHandlingStrategy(logger, settings)) .SetMessageDeserializer(new JsonMessageDeserializer <T>()) .SetLogger(logger) .CreateDefaultBinding(); }
private static ILog CreateLogWithSlack(IServiceCollection services, IReloadingManager <AppSettings> settings) { var consoleLogger = new LogToConsole(); var aggregateLogger = new AggregateLogger(); aggregateLogger.AddLog(consoleLogger); //It is possible to run only with console logger if (!string.IsNullOrEmpty(settings.CurrentValue.EthereumIndexer.DB.LogsConnectionString) && !string.IsNullOrEmpty(settings.CurrentValue.SlackNotifications.AzureQueue.ConnectionString)) { var dbLogConnectionStringManager = settings.Nested(x => x.EthereumIndexer.DB.LogsConnectionString); var dbLogConnectionString = dbLogConnectionStringManager.CurrentValue; if (string.IsNullOrEmpty(dbLogConnectionString)) { consoleLogger.WriteWarningAsync(nameof(Startup), nameof(CreateLogWithSlack), "Table loggger is not inited").Wait(); return(aggregateLogger); } if (dbLogConnectionString.StartsWith("${") && dbLogConnectionString.EndsWith("}")) { throw new InvalidOperationException($"LogsConnString {dbLogConnectionString} is not filled in settings"); } var persistenceManager = new LykkeLogToAzureStoragePersistenceManager( AzureTableStorage <LogEntity> .Create(dbLogConnectionStringManager, "EthereumSamuraiApiLog", consoleLogger), consoleLogger); if (settings.CurrentValue.SlackNotifications != null) { } // Creating slack notification service, which logs own azure queue processing messages to aggregate log var slackService = services.UseSlackNotificationsSenderViaAzureQueue(new AzureQueueIntegration.AzureQueueSettings { ConnectionString = settings.CurrentValue.SlackNotifications.AzureQueue.ConnectionString, QueueName = settings.CurrentValue.SlackNotifications.AzureQueue.QueueName }, aggregateLogger); var slackNotificationsManager = new LykkeLogToAzureSlackNotificationsManager(slackService, consoleLogger); // Creating azure storage logger, which logs own messages to concole log var azureStorageLogger = new LykkeLogToAzureStorage( persistenceManager, slackNotificationsManager, consoleLogger); azureStorageLogger.Start(); aggregateLogger.AddLog(azureStorageLogger); } return(aggregateLogger); }
private ILog CreateLogWithSlack(IServiceCollection services, IReloadingManager <AppSettings> settings) { var aggregateLogger = new AggregateLogger(); var consoleLog = new LogToConsole(); aggregateLogger.AddLog(consoleLog); var dbLogConnectionStringManager = settings.Nested(x => x.TradesConverterJob.Db.LogsConnString); var dbLogConnectionString = dbLogConnectionStringManager.CurrentValue; if (string.IsNullOrEmpty(dbLogConnectionString)) { consoleLog.WriteWarning(nameof(Startup), nameof(CreateLogWithSlack), "Table loggger is not inited"); return(aggregateLogger); } if (dbLogConnectionString.StartsWith("${") && dbLogConnectionString.EndsWith("}")) { throw new InvalidOperationException($"LogsConnString {dbLogConnectionString} is not filled in settings"); } var persistenceManager = new LykkeLogToAzureStoragePersistenceManager( AzureTableStorage <LogEntity> .Create(dbLogConnectionStringManager, "TradesConverterLog", consoleLog), consoleLog); // Creating slack notification service, which logs own azure queue processing messages to aggregate log var slackService = services.UseSlackNotificationsSenderViaAzureQueue(new AzureQueueIntegration.AzureQueueSettings { ConnectionString = settings.CurrentValue.SlackNotifications.AzureQueue.ConnectionString, QueueName = settings.CurrentValue.SlackNotifications.AzureQueue.QueueName }, aggregateLogger); var slackNotificationsManager = new LykkeLogToAzureSlackNotificationsManager( slackService, new HashSet <string> { LykkeLogToAzureStorage.ErrorType, LykkeLogToAzureStorage.FatalErrorType, LykkeLogToAzureStorage.MonitorType }, consoleLog); var azureStorageLogger = new LykkeLogToAzureStorage( persistenceManager, slackNotificationsManager, consoleLog); azureStorageLogger.Start(); aggregateLogger.AddLog(azureStorageLogger); var logToSlack = LykkeLogToSlack.Create(slackService, "Bridges", LogLevel.Error | LogLevel.FatalError | LogLevel.Warning); aggregateLogger.AddLog(logToSlack); return(aggregateLogger); }
private void RegisterRepositories(IReloadingManager <AppSettings> config, IServiceCollection services) { var consoleLogger = new LogToConsole(); // Wire up azure connections var connectionString = config.ConnectionString(a => a.ServiceSettings.Db.Azure); services.AddTransient <INosqlRepo <ObservableWalletEntity>, AzureRepo <ObservableWalletEntity> >(e => new AzureRepo <ObservableWalletEntity>( AzureTableStorage <ObservableWalletEntity> .Create(connectionString, "ObservableWallet", consoleLogger) )); services.AddTransient <INosqlRepo <ObservableAddressEntity>, AzureRepo <ObservableAddressEntity> >(e => new AzureRepo <ObservableAddressEntity>( AzureTableStorage <ObservableAddressEntity> .Create(connectionString, "ObservableAddress", consoleLogger) )); services.AddTransient <INosqlRepo <UnsignedTransactionEntity>, AzureRepo <UnsignedTransactionEntity> >(e => new AzureRepo <UnsignedTransactionEntity>( AzureTableStorage <UnsignedTransactionEntity> .Create(connectionString, "UnsignedTransactionEntity", consoleLogger) )); services.AddTransient <INosqlRepo <BroadcastedTransactionByHash>, AzureRepo <BroadcastedTransactionByHash> >(e => new AzureRepo <BroadcastedTransactionByHash>( AzureTableStorage <BroadcastedTransactionByHash> .Create(connectionString, "BroadcastedTransactionByHash", consoleLogger) )); services.AddTransient <INosqlRepo <BroadcastedTransaction>, AzureRepo <BroadcastedTransaction> >(e => new AzureRepo <BroadcastedTransaction>( AzureTableStorage <BroadcastedTransaction> .Create(connectionString, "BroadcastedTransaction", consoleLogger) )); services.AddTransient <INosqlRepo <BroadcastedOutpoint>, AzureRepo <BroadcastedOutpoint> >(e => new AzureRepo <BroadcastedOutpoint>( AzureTableStorage <BroadcastedOutpoint> .Create(connectionString, "BroadcastedOutpoint", consoleLogger) )); services.AddScoped <IDbConnection, NpgsqlConnection>((p) => { var dcrdataConnectionString = config.CurrentValue.ServiceSettings.Db.Dcrdata; var sqlClient = new NpgsqlConnection(dcrdataConnectionString); sqlClient.Open(); return(sqlClient); }); services.AddTransient <IBlockRepository, BlockRepository>(); services.AddTransient <IAddressRepository, AddressRepository>(); services.AddTransient <ITransactionRepository, TransactionRepository>(); }
private static ILog CreateLogWithSlack(IServiceCollection services, IReloadingManager <AppSettings> settings) { var consoleLogger = new LogToConsole(); var aggregateLogger = new AggregateLogger(); aggregateLogger.AddLog(consoleLogger); // Creating slack notification service, which logs own azure queue processing messages to aggregate log var slackService = services.UseSlackNotificationsSenderViaAzureQueue(new AzureQueueIntegration.AzureQueueSettings { ConnectionString = settings.CurrentValue.SlackNotifications.AzureQueue.ConnectionString, QueueName = settings.CurrentValue.SlackNotifications.AzureQueue.QueueName }, aggregateLogger); var dbLogConnectionStringManager = settings.Nested(x => x.BitcoinCashApi.Db.LogsConnString); var dbLogConnectionString = dbLogConnectionStringManager.CurrentValue; // Creating azure storage logger, which logs own messages to concole log if (!string.IsNullOrEmpty(dbLogConnectionString) && !(dbLogConnectionString.StartsWith("${") && dbLogConnectionString.EndsWith("}"))) { var persistenceManager = new LykkeLogToAzureStoragePersistenceManager( AzureTableStorage <LogEntity> .Create(dbLogConnectionStringManager, "BitcoinCashApiLog", consoleLogger), consoleLogger); var slackNotificationsManager = new LykkeLogToAzureSlackNotificationsManager(slackService, consoleLogger); var azureStorageLogger = new LykkeLogToAzureStorage( persistenceManager, slackNotificationsManager, consoleLogger); azureStorageLogger.Start(); aggregateLogger.AddLog(azureStorageLogger); var allMessagesSlackLogger = LykkeLogToSlack.Create ( slackService, "BlockChainIntegration", // ReSharper disable once RedundantArgumentDefaultValue LogLevel.All ); aggregateLogger.AddLog(allMessagesSlackLogger); var importantMessagesSlackLogger = LykkeLogToSlack.Create ( slackService, "BlockChainIntegrationImportantMessages", LogLevel.All ^ LogLevel.Info ); aggregateLogger.AddLog(importantMessagesSlackLogger); } return(aggregateLogger); }
public static void Example(RabbitMqSubscriptionSettings settings) { var looger = new LogToConsole(); _connector = new RabbitMqSubscriber <string>(settings, new DefaultErrorHandlingStrategy(looger, settings)) .SetMessageDeserializer(new TestMessageDeserializer()) .CreateDefaultBinding() .Subscribe(HandleMessage) .Start(); }
public static void Main(string[] args) { // Initialize logger var consoleLog = new LogToConsole(); var logAggregate = new LogAggregate() .AddLogger(consoleLog); var log = logAggregate.CreateLogger(); try { log.Info("Reading application settings."); var config = new ConfigurationBuilder() //.AddJsonFile("appsettings.json", optional: true) .AddEnvironmentVariables() .Build(); var settingsUrl = config.GetValue <string>("BROKER_SETTINGS_URL"); log.Info("Loading app settings from web-site."); var appSettings = LoadSettings(settingsUrl); log.Info("Initializing azure/slack logger."); var services = new ServiceCollection(); // only used for azure logger logAggregate.ConfigureAzureLogger(services, Startup.ApplicationName, appSettings); log = logAggregate.CreateLogger(); // After log is configured // log.Info("Creating Startup."); var startup = new Startup(appSettings, log); log.Info("Configure startup services."); startup.ConfigureServices(Application.Instance.ContainerBuilder, log); log.Info("Starting application."); var scope = Application.Instance.Start(); log.Info("Configure startup."); startup.Configure(scope); log.Info("Running application."); Application.Instance.Run(); log.Info("Exit application."); } catch (Exception ex) { log.WriteErrorAsync("Program", string.Empty, string.Empty, ex).Wait(); } }
// This method gets called by the runtime. Use this method to add services to the container. public IServiceProvider ConfigureServices(IServiceCollection services) { ILog log = new LogToConsole(); try { // Add framework services. services.AddMvc(); // Add swagger generator services.AddSwaggerGen(x => { x.SwaggerDoc(ApiVersion, new Info { Title = ApiTitle, Version = ApiVersion }); }); // Load settings var settingsUrl = Configuration["SettingsUrl"]; var httpClient = new HttpClient(); var response = httpClient.GetAsync(settingsUrl).Result; var settingsString = response.Content.ReadAsStringAsync().Result; var settings = Newtonsoft.Json.JsonConvert.DeserializeObject <AppSettings>(settingsString); if (null != settings.EmailSenderSettings.Log) { var logToTable = new LogToTable(settings.EmailSenderSettings.Log.ConnectionString, settings.EmailSenderSettings.Log.TableName, log); log = new LogToAll(log, logToTable); } // Register dependencies, populate the services from // the collection, and build the container. If you want // to dispose of the container at the end of the app, // be sure to keep a reference to it as a property or field. var builder = new ContainerBuilder(); builder.RegisterInstance( new AzureTableStorage <PartnerSmtpSettings>(settings.EmailSenderSettings.Partners.ConnectionString, settings.EmailSenderSettings.Partners.TableName, log)) .As <INoSQLTableStorage <PartnerSmtpSettings> >() .SingleInstance(); builder.Populate(services); ApplicationContainer = builder.Build(); // Create the IServiceProvider based on the container. return(new AutofacServiceProvider(ApplicationContainer)); } catch (Exception ex) { log.WriteFatalErrorAsync(nameof(EmailSender), nameof(Startup), nameof(ConfigureServices), ex, DateTime.UtcNow).Wait(); throw; } }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { // Add framework services. services.AddApplicationInsightsTelemetry(Configuration); services.AddMvc(); var storageConnectionString = Configuration.Get <string>("ConnectionString"); if (string.IsNullOrWhiteSpace(storageConnectionString)) { storageConnectionString = "UseDevelopmentStorage=true"; } var bitcoinRpcSettings = new BitcoinRpcSettings { Url = new Uri(Configuration.Get <string>("RpcHostPort")), Password = Configuration.Get <string>("RpcPassword"), User = Configuration.Get <string>("RpcUser") }; services.AddInstance(new BitcoinRpcClient(bitcoinRpcSettings)); var bitcoinNinjaSettings = new BitcoinNinjaSettings { //UrlMain = new Uri(Configuration.Get<string>("UrlMainNinja")), UrlTest = new Uri(Configuration.Get <string>("UrlTestNetNinja")), Network = (Network)Enum.Parse(typeof(Network), Configuration.Get <string>("Network")) }; services.AddInstance <IBitcoinNinjaClient>(new BitcoinNinjaClient(bitcoinNinjaSettings)); var coniprismApiSettings = new CoinprismApiSettings { UrlMain = new Uri(Configuration.Get <string>("UrlCoinprismApi")), UrlTest = new Uri(Configuration.Get <string>("UrlCoinprismApiTestnet")), Network = (Network)Enum.Parse(typeof(Network), Configuration.Get <string>("Network")) }; services.AddInstance <ICoinprismClient>(new CoinprismClient(coniprismApiSettings)); var log = new LogToConsole(); services.AddInstance <ILog>(log); AppInfo.Version = Configuration.Get <string>("version"); services.BindAzureRepositories(storageConnectionString, log); }
public ContainerBuilder Bind(BaseSettings settings) { /* * var logToTable = new LogToTable(); * var log = new LogToTableAndConsole(logToTable, new LogToConsole()); * var ioc = new ContainerBuilder(); * InitContainer(ioc, settings, log); * return ioc; */ var log = new LogToConsole(); var ioc = new ContainerBuilder(); InitContainer(ioc, settings, log); return(ioc); }
public static void Main(string[] args) { var log = new LogToConsole(); var generatorSettings = new EmailContentGeneratorSettings { BaseUrl = "" }; var contentGenerator = new EmailContentGenerator(generatorSettings, log); var content = contentGenerator.GenerateWelcomeFxTemplateAsync().Result; Console.WriteLine(content); Console.ReadLine(); }
private void Update(EvaluationContext context) { var deviceContext = _d3dDevice.ImmediateContext; bool enabled = Enabled.GetValue(context); bool logToConsole = LogToConsole.GetValue(context); if (enabled && _readyToMeasure) { _queryTimeStampDisjoint.Begin(deviceContext); _queryTimeStampFrameBegin.End(deviceContext); } Command.GetValue(context); if (!enabled) { return; } if (_readyToMeasure) { _queryTimeStampFrameEnd.End(deviceContext); _queryTimeStampDisjoint.End(deviceContext); _readyToMeasure = false; } else { // check if last measurement is ready bool dataFetched = true; dataFetched &= _queryTimeStampDisjoint.GetData(deviceContext, AsynchronousFlags.None, out QueryDataTimestampDisjoint disjointData); dataFetched &= _queryTimeStampFrameBegin.GetData(deviceContext, AsynchronousFlags.None, out long timeStampframeBegin); dataFetched &= _queryTimeStampFrameEnd.GetData(deviceContext, AsynchronousFlags.None, out long timeStampframeEnd); if (dataFetched && !disjointData.Disjoint) { float durationInS = (float)(timeStampframeEnd - timeStampframeBegin) / disjointData.Frequency; int usDuration = (int)(durationInS * 1000f * 1000f); if (logToConsole) { Log.Debug($"Subtree took: {usDuration}us on GPU."); } LastMeasureInMicroSeconds = usDuration; _readyToMeasure = true; } LastMeasureInMs = MathUtils.Lerp(LastMeasureInMs, (float)(LastMeasureInMicroSeconds / 1000.0), 0.03f); } }
public IServiceProvider ConfigureServices(IServiceCollection services) { services.AddMvc() .AddJsonOptions(options => { options.SerializerSettings.ContractResolver = new Newtonsoft.Json.Serialization.DefaultContractResolver(); }); services.AddSwaggerGen(options => { options.SingleApiVersion(new Info { Version = "v1", Title = "Api" }); options.DescribeAllEnumsAsStrings(); }); var builder = new ContainerBuilder(); var appSettings = Configuration.LoadSettings <ApplicationSettings>() .Nested(s => { if (!string.IsNullOrEmpty(Configuration["Env"])) { s.MtPublic.Env = Configuration["Env"]; Console.WriteLine($"Env: {s.MtPublic.Env}"); } return(s); }); var settings = appSettings.Nested(s => s.MtPublic); var consoleLogger = new LogToConsole(); services.UseLogToAzureStorage(settings.Nested(s => s.Db.LogsConnString), null, "MarginTradingPublicLog", consoleLogger); builder.RegisterModule(new PublicApiModule(settings.CurrentValue)); builder.Populate(services); ApplicationContainer = builder.Build(); return(new AutofacServiceProvider(ApplicationContainer)); }
private static void SetupLoggers(IServiceCollection services, IReloadingManager <AppSettings> mtSettings, IReloadingManager <DataReaderSettings> settings) { var consoleLogger = new LogToConsole(); var commonSlackService = services.UseSlackNotificationsSenderViaAzureQueue(mtSettings.CurrentValue.SlackNotifications.AzureQueue, new LogToConsole()); var slackService = new MtSlackNotificationsSender(commonSlackService, "MT DataReader", settings.CurrentValue.Env); var log = services.UseLogToAzureStorage(settings.Nested(s => s.Db.LogsConnString), slackService, "MarginTradingDataReaderLog", consoleLogger); LogLocator.CommonLog = log; }
private ILog CreateLogWithSlack(IServiceCollection services, IReloadingManager <AppSettings> settings) { _console = new LogToConsole(); var aggregateLogger = new AggregateLogger(); aggregateLogger.AddLog(_console); var dbLogConnectionStringManager = settings.Nested(x => x.TradeVolumesService.LogsConnString); var dbLogConnectionString = dbLogConnectionStringManager.CurrentValue; if (string.IsNullOrEmpty(dbLogConnectionString)) { _console.WriteWarning(nameof(Startup), nameof(CreateLogWithSlack), "Table loggger is not inited"); return(aggregateLogger); } if (dbLogConnectionString.StartsWith("${") && dbLogConnectionString.EndsWith("}")) { throw new InvalidOperationException($"LogsConnString {dbLogConnectionString} is not filled in settings"); } var persistenceManager = new LykkeLogToAzureStoragePersistenceManager( AzureTableStorage <LogEntity> .Create(dbLogConnectionStringManager, "TradeVolumesLog", _console), _console); // Creating slack notification service, which logs own azure queue processing messages to aggregate log var slackService = services.UseSlackNotificationsSenderViaAzureQueue(new AzureQueueIntegration.AzureQueueSettings { ConnectionString = settings.CurrentValue.SlackNotifications.AzureQueue.ConnectionString, QueueName = settings.CurrentValue.SlackNotifications.AzureQueue.QueueName }, aggregateLogger); var slackNotificationsManager = new LykkeLogToAzureSlackNotificationsManager(slackService, _console); // Creating azure storage logger, which logs own messages to concole log var azureStorageLogger = new LykkeLogToAzureStorage( persistenceManager, slackNotificationsManager, _console); azureStorageLogger.Start(); aggregateLogger.AddLog(azureStorageLogger); return(aggregateLogger); }