From 739fcaf6f657fd958a4eef9cc196e33f37823b5d Mon Sep 17 00:00:00 2001 From: jcala Date: Mon, 25 Jun 2018 14:42:20 +0200 Subject: [PATCH] basic logging definitions added --- composer.json | 3 +- .../Logger/BasicLoggingDefinitions.php | 30 +++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 src/SAREhub/Commons/Logger/BasicLoggingDefinitions.php diff --git a/composer.json b/composer.json index e0b148f..5ffc857 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,8 @@ "roave/better-reflection": "dev-master#c87d856", "guzzlehttp/guzzle": "~6.0", "nannehuiges/jsend": "2.1.*", - "monolog/monolog": "1.*" + "monolog/monolog": "1.*", + "php-di/php-di": "^6.0" }, "require": { "php": "^7.1" diff --git a/src/SAREhub/Commons/Logger/BasicLoggingDefinitions.php b/src/SAREhub/Commons/Logger/BasicLoggingDefinitions.php new file mode 100644 index 0000000..252148d --- /dev/null +++ b/src/SAREhub/Commons/Logger/BasicLoggingDefinitions.php @@ -0,0 +1,30 @@ + autowire() + ->constructorParameter("level", factory(EnvLoggingLevelProvider::class)) + ->constructorParameter("formatter", create(DefaultJsonLogFormatter::class)), + LoggerFactory::class => factory(StreamLoggerFactoryProvider::class) + ]; + } + + public static function inject(CreateDefinitionHelper $definition, string $loggerName): DefinitionHelper + { + return $definition->method("setLogger", factory(LoggerFactory::class . "::create") + ->parameter("name", $loggerName)); + } +} \ No newline at end of file