Skip to content

Commit

Permalink
Merge pull request #41 from SAREhub/basic_logging_definitions
Browse files Browse the repository at this point in the history
basic logging definitions added
  • Loading branch information
kuba9392 authored Jun 25, 2018
2 parents 33c556b + 739fcaf commit ecb257e
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 ecb257e

Please sign in to comment.