Skip to content

Commit

Permalink
Fix up
Browse files Browse the repository at this point in the history
  • Loading branch information
inverse committed Feb 21, 2024
1 parent b0eaa60 commit 1f1dca0
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions example.config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ telegram:
# Logger configuration
logger:
level: info
log_to_file: false # If true will log to file as well as stdout

# Configure rules
rules:
Expand Down
2 changes: 1 addition & 1 deletion serverless.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public function handle($event, Context $context)
$configLoader = new ConfigParser();
$config = $configLoader->parse(Yaml::parseFile(__DIR__ . '/config.yml'));

$container = new Container($config);
$container = new Container($config, 'serverless');

$termin = $container->getTermin();
$termin->run($config->getSites());
Expand Down
6 changes: 3 additions & 3 deletions src/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ class Container extends Pimple
{
private const ROOT_DIR = __DIR__.'/../';

public function __construct(Config $config)
public function __construct(Config $config, string $runtime = 'normal')
{
parent::__construct();

$this[NotifierInterface::class] = static fn () => (new NotifierFactory(new MultiNotifier()))->create($config);

$this[LoggerInterface::class] = static function () use ($config) {
$this[LoggerInterface::class] = static function () use ($config, $runtime) {
$logger = new Logger('termin');
if ($config->getLogToFile()) {
if ($config->getLogToFile() || 'serverless' !== $runtime) {
$logger->pushHandler(new StreamHandler(self::ROOT_DIR.'var/log/app.log', $config->getLogLevel()));
}
$logger->pushHandler(new StreamHandler('php://stdout', $config->getLogLevel()));
Expand Down

0 comments on commit 1f1dca0

Please sign in to comment.