Skip to content

Commit

Permalink
basic logging definitions added
Browse files Browse the repository at this point in the history
  • Loading branch information
jcala committed Jun 25, 2018
1 parent 33c556b commit 739fcaf
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
30 changes: 30 additions & 0 deletions src/SAREhub/Commons/Logger/BasicLoggingDefinitions.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php


namespace SAREhub\Commons\Logger;


use function DI\autowire;
use function DI\create;
use DI\Definition\Helper\CreateDefinitionHelper;
use DI\Definition\Helper\DefinitionHelper;
use function DI\factory;

class BasicLoggingDefinitions
{
public static function get(): array
{
return [
StreamLoggerFactoryProvider::class => 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));
}
}

0 comments on commit 739fcaf

Please sign in to comment.