Ejemplo n.º 1
0
 public function getLogger()
 {
     $logger = new Logger();
     $logger->handler(Variable::init($this->log));
     $logger->format("%3\$d %4\$s\n");
     return $logger;
 }
Ejemplo n.º 2
0
<?php

require 'SplClassLoader.php';
$loader = new SplClassLoader('Analog', '../lib');
$loader->register();
use Analog\Analog;
$log = '';
Analog::handler(\Analog\Handler\Variable::init($log));
Analog::log('Test one');
Analog::log('Test two');
echo $log;
Ejemplo n.º 3
0
use Analog\Analog;
session_start();
$session =& $_SESSION['bachviewer'];
require APP_DIR . '/../vendor/autoload.php';
if (defined('VIEWER_XHPROF_PATH') && function_exists('xhprof_enable')) {
    $profiler = new Bach\XHProf();
    $profiler->start();
}
$logger = null;
$log_lvl = Analog::ERROR;
if (APP_DEBUG === true) {
    $log_lvl = Analog::DEBUG;
}
if (defined('APP_TESTS')) {
    $viewer_log = '';
    $logger = \Analog\Handler\Variable::init($viewer_log);
} else {
    $log_dir = APP_DIR . '/logs/';
    if (defined('APP_LOGS')) {
        $log_dir = APP_LOGS;
    }
    if (!file_exists($log_dir)) {
        throw new \RuntimeException('Log directory (' . $log_dir . ') does not exists!');
    } else {
        if (!is_writeable($log_dir)) {
            throw new \RuntimeException('Log directory (' . $log_dir . ') is not writeable!');
        }
    }
    $log_file = $log_dir . 'viewer.log';
    $logger = \Analog\Handler\File::init($log_file);
}
Ejemplo n.º 4
0
    $galette_run_log = null;
    $galette_log_var = null;
    if (GALETTE_MODE === 'DEV' || $cron || defined('GALETTE_SYS_LOG') && GALETTE_SYS_LOG === true) {
        //logs everything in PHP logs (per chance /var/log/http/error_log)
        $galette_run_log = \Analog\Handler\Stderr::init();
    } else {
        if (!$installer || $installer && defined('GALETTE_LOGGER_CHECKED')) {
            //logs everything in galette log file
            if (!isset($logfile)) {
                //if no filename has been setetd (ie. from install), set default one
                $logfile = 'galette_run';
            }
            $log_path = GALETTE_LOGS_PATH . $logfile . '_' . $now->format('Y-m-d') . '.log';
            $galette_run_log = \Analog\Handler\File::init($log_path);
        } else {
            $galette_run_log = \Analog\Handler\Variable::init($galette_log_var);
        }
    }
    Core\Logs::cleanup();
}
Analog::handler(\Analog\Handler\Multi::init(array(Analog::URGENT => $galette_run_log, Analog::ALERT => $galette_run_log, Analog::CRITICAL => $galette_run_log, Analog::ERROR => $galette_run_log, Analog::WARNING => GALETTE_LOG_LVL >= Analog::WARNING ? $galette_run_log : $galette_null_log, Analog::NOTICE => GALETTE_LOG_LVL >= Analog::NOTICE ? $galette_run_log : $galette_null_log, Analog::INFO => GALETTE_LOG_LVL >= Analog::INFO ? $galette_run_log : $galette_null_log, Analog::DEBUG => GALETTE_LOG_LVL >= Analog::DEBUG ? $galette_debug_log : $galette_null_log)));
require_once GALETTE_ROOT . 'includes/functions.inc.php';
$session_name = null;
//since PREFIX_DB and NAME_DB are required to properly instanciate sessions,
// we have to check here if they're assigned
if ($installer || !defined('PREFIX_DB') || !defined('NAME_DB')) {
    $session_name = 'galette_install';
} else {
    $session_name = PREFIX_DB . '_' . NAME_DB;
}
$session =& $_SESSION['galette'][$session_name];