Permalink
Browse files

Create new logs folder, App and Controller startup are logged for debug

  • Loading branch information...
Art4 committed Aug 22, 2017
1 parent a2f6e25 commit a5172ecd18c019909888ca501a8299fe8523dc48
Showing with 42 additions and 0 deletions.
  1. +1 −0 .gitignore
  2. +34 −0 bootstrap.php
  3. 0 logs/.gitkeep
  4. +2 −0 src/Application/App.php
  5. +5 −0 src/Application/ControllerAbstract.php
View
@@ -3,4 +3,5 @@ composer.phar
composer.lock
config/custom.php
Deciphers.log
logs/*
vendor
View
@@ -81,6 +81,40 @@ function($custom = 'custom')
$container->set('cache', $cache);
// Create Logger
$now = new \DateTime('now', new \DateTimeZone($config->get('default_timezone')));
$filepath = sprintf(
'%s' . \DIRECTORY_SEPARATOR . '%s',
__DIR__ . \DIRECTORY_SEPARATOR . 'logs',
$now->format('Y')
);
if ( ! file_exists($filepath) )
{
mkdir($filepath);
}
$stream = fopen(
$filepath . \DIRECTORY_SEPARATOR . $now->format('Y-m-d') . '.log',
'a+'
);
$handler = new \YoutubeDownloader\Logger\Handler\StreamHandler($stream, [
\YoutubeDownloader\Logger\LogLevel::EMERGENCY,
\YoutubeDownloader\Logger\LogLevel::ALERT,
\YoutubeDownloader\Logger\LogLevel::CRITICAL,
\YoutubeDownloader\Logger\LogLevel::ERROR,
\YoutubeDownloader\Logger\LogLevel::WARNING,
\YoutubeDownloader\Logger\LogLevel::NOTICE,
\YoutubeDownloader\Logger\LogLevel::INFO,
\YoutubeDownloader\Logger\LogLevel::DEBUG,
]);
$logger = new \YoutubeDownloader\Logger\HandlerAwareLogger($handler);
$container->set('logger', $logger);
return $container;
},
[getenv('CONFIG_ENV') ?: 'custom']
View
No changes.
View
@@ -29,6 +29,8 @@ class App
public function __construct(Container $container)
{
$this->container = $container;
$this->getContainer()->get('logger')->debug('App started');
}
/**
@@ -19,6 +19,11 @@
public function __construct(App $app)
{
$this->app = $app;
$this->get('logger')->debug(
'{controller_name} created',
['controller_name' => get_class($this)]
);
}
/**

0 comments on commit a5172ec

Please sign in to comment.