internal static MongoDbSM Init(MongoDBStore config) { if (config is null) { throw new StruLogConfigException($"Not found configuration for '{NAME}' store"); } if (@this == null) { @this = new MongoDbSM(config); } return(@this); }
private MongoDbSM(MongoDBStore config) { client = new MongoClient(config.connectionString); var db = client.GetDatabase(config.dbName); logsCollection = db.GetCollection <LogDataModel>(config.collectionName); //Если она не существует, неявно создастся Config = config; ProcessingQueueSize = 1_000_000; ProcessingQueue = new BlockingCollection <LogData>(ProcessingQueueSize); AccessAttemptsDelays_mSeconds = new int[] { 25, 45, 90, 250, 500, 1000, 3000, 5000 }; Logger = LoggersFactory.GetLogger <MongoDbSM>(true); MinLogLevel = config.minLogLevel; }
private static MongoDBStore ParseMongoDbStoreSettings() { var stores = jsonDoc.SelectToken(nameof(Config.stores)); var mongoDB = stores.SelectToken(MongoDbSM.NAME); var mongoDBStore = new MongoDBStore { connectionString = mongoDB.Value <string>(nameof(MongoDBStore.connectionString)), minLogLevel = mongoDB.Value <string>(nameof(MongoDBStore.minLogLevel)).StringToEnum <LogLevel>(), outputPattern = DbStoreManager.GetOutputActions(mongoDB.Value <string>(nameof(MongoDBStore.outputPattern))), collectionName = mongoDB.Value <string>(nameof(MongoDBStore.collectionName)).Replace("{projectName}", Config.projectName), dbName = mongoDB.Value <string>(nameof(MongoDBStore.dbName)) }; return(mongoDBStore); }