1 /** 2 * Модуль файлового логера 3 * 4 * Copyright: (c) 2015-2017, Milofon Project. 5 * License: Subject to the terms of the BSD license, as written in the included LICENSE.txt file. 6 * Authors: Maksim Galanin 7 */ 8 module dango.system.logging.loggers.file; 9 10 private 11 { 12 import vibe.core.log; 13 import vibe.core.concurrency: lock; 14 15 import proped: Properties; 16 17 import dango.system.logging.core; 18 } 19 20 21 /** 22 * Фабрика создающая файловый логгер 23 */ 24 class FileLoggerFactory : LoggerFactory 25 { 26 shared(Logger) createLogger(Properties config) 27 { 28 string fileName = config.getOrElse("file", "trand.log"); 29 LogLevel level = matchLogLevel(config.getOrElse("level", "info")); 30 31 FileLogger.Format logFormat = matchLogFormat(config.getOrElse("errorFormat", "plain")); 32 FileLogger.Format logInfoFormat = matchLogFormat(config.getOrElse("infoFormat", "plain")); 33 34 auto result = cast(shared)new FileLogger(fileName); 35 { 36 auto l = result.lock(); 37 l.minLevel = level; 38 l.format = logFormat; 39 l.infoFormat = logInfoFormat; 40 } 41 42 return result; 43 } 44 }