Skip to content
Permalink
Browse files

Added Monolog

  • Loading branch information...
karsasmus committed Mar 15, 2017
1 parent df22c95 commit 7c514ee2a338152e0f74d600e63fe065d0ba4c52
Showing with 230 additions and 30 deletions.
  1. +1 −0 .gitignore
  2. +21 −1 app/source/classes/Leafpub.php
  3. +2 −1 composer.json
  4. +206 −28 composer.lock
@@ -8,6 +8,7 @@ npm-debug.log
/app/db_upload_fix.php
/app/source/assets
/app/source/vendor
/app/log
/design
/dist
/node_modules
@@ -25,7 +25,7 @@ class Leafpub {
/**
* Properties
**/
protected static $database, $language, $listeners, $dispatcher;
protected static $database, $language, $listeners, $dispatcher, $logger;
/**
* Initialize the app
@@ -35,16 +35,27 @@ class Leafpub {
*
**/
public static function run() {
self::$logger = new \Monolog\Logger('Leafpub::Logger');
$logLvl = \Monolog\Logger::INFO;
if(LEAFPUB_DEV == 1){
self::$logger->pushProcessor(new \Monolog\Processor\IntrospectionProcessor());
$logLvl = \Monolog\Logger::DEBUG;
}
self::$logger->pushHandler(new \Monolog\Handler\RotatingFileHandler(Leafpub::path('log/leafpub.log'), 30, $logLvl));
self::$logger->debug('Startup...');
// Connect to the database
try {
self::$logger->debug('Connecting to database');
Database::connect();
} catch(\Exception $e) {
switch($e->getCode()) {
case Database::NOT_CONFIGURED:
// Database isn't configured, launch the installer
self::$logger->error('Database isn\'t configured');
header('Location: ' . self::url('source/installer/'));
exit();
default:
self::$logger->error('Database Error: ' . $e->getMessage());
$title = 'Database Error';
$message = 'Unable to connect to the database: ' . $e->getMessage();
}
@@ -57,6 +68,7 @@ public static function run() {
// Load settings
try {
self::$logger->debug('Load settings');
Setting::load();
} catch(\Exception $e) {
exit(Error::system([
@@ -67,6 +79,7 @@ public static function run() {
// Load the language pack
try {
self::$logger->debug('Load language');
Language::load(Setting::getOne('language'));
} catch(\Exception $e) {
exit(Error::system([
@@ -82,6 +95,7 @@ public static function run() {
date_default_timezone_set(Setting::getOne('timezone'));
// Create the Symfony EventDispatcher
self::$logger->debug('Create event dispatcher');
self::$dispatcher = new EventDispatcher();
self::_registerCoreListener();
}
@@ -101,16 +115,22 @@ private static function _registerCoreListener(){
self::on(Events\Upload\GenerateThumbnail::NAME, __NAMESPACE__ . '\Models\Upload::handleThumbnail', -999);
}
public static function getLogger(){
return self::$logger;
}
public static function registerPlugins(\Slim\App $app){
// Only register plugins if the static array is null.
if (Plugin::$plugins == null){
self::$logger->debug('Register plugins');
try {
$plugins = Plugin::getActivatedPlugins();
foreach($plugins as $plugin){
$ns = $plugin['dir'];
$class = 'Leafpub\\Plugins\\' . $ns . '\\Plugin';
$pls[$ns] = new $class($app);
self::$logger->debug('Register plugin \'' . $ns . '\'');
}
Plugin::$plugins = $pls;
} catch (\Exception $e){
@@ -15,7 +15,8 @@
"mpratt/embera": "^1.9",
"symfony/event-dispatcher": "^3.1",
"composer/semver": "^1.4.2",
"zendframework/zend-db": "^2.7"
"zendframework/zend-db": "^2.7",
"monolog/monolog": "^1.0"
},
"config": {
"vendor-dir": "app/source/vendor"
Oops, something went wrong.

0 comments on commit 7c514ee

Please sign in to comment.
You can’t perform that action at this time.