-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlogging.php
More file actions
executable file
·53 lines (42 loc) · 1.43 KB
/
Copy pathlogging.php
File metadata and controls
executable file
·53 lines (42 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
// ==============================================================
// Copyright (C) 2014 Mark Vejvoda
// Under GNU GPL v3.0
// ==============================================================
if ( defined('INCLUSION_PERMITTED') === false ||
(defined('INCLUSION_PERMITTED') === true && INCLUSION_PERMITTED === false)) {
die( 'This file must not be invoked directly.' );
}
if(defined('__RIPRUNNER_ROOT__') === false) {
define('__RIPRUNNER_ROOT__', dirname(__FILE__));
}
require __DIR__ . '/vendor/autoload.php';
// Use Monolog's `Logger` namespace:
use Monolog\Logger;
use Monolog\Handler\StreamHandler;
$log = null;
// The model class handling variable requests dynamically
class AppLogger extends Logger {
public function trace($msg) {
parent::info($msg);
}
public function getRootLoggerPath() {
return $this->log->getHandlers()[0]->getUrl();
}
}
$log = new AppLogger('myLogger');
// Declare a new handler and store it in the $logstream variable
// This handler will be triggered by events of log level INFO and above
$logstream = new StreamHandler(__RIPRUNNER_ROOT__ . '/application.log', Logger::WARNING);
// Push the $logstream handler onto the Logger object
$log->pushHandler($logstream);
function throwExceptionAndLogError($ui_error_msg, $log_error_msg) {
global $log;
try {
throw new \Exception($log_error_msg);
}
catch(Exception $ex) {
if($log != null) $log->error($ui_error_msg, $ex);
die($ui_error_msg);
}
}