forked from CoderKungfu/php-queue
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLogger.php
More file actions
33 lines (29 loc) · 987 Bytes
/
Copy pathLogger.php
File metadata and controls
33 lines (29 loc) · 987 Bytes
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
<?php
namespace PHPQueue;
class Logger extends \Monolog\Logger
{
public static $all_logs = array();
/**
* @param string $logName
* @param int $logLevel
* @param string $logPath
* @return \PHPQueue\Logger
*/
public static function createLogger($logName=null, $logLevel = Logger::WARNING, $logPath=null)
{
if (empty(self::$all_logs[$logName])) {
$logger = new self($logName);
$logger->pushHandler(new \Monolog\Handler\StreamHandler($logPath, $logLevel));
self::$all_logs[$logName] = $logger;
}
return self::$all_logs[$logName];
}
public static function cycleLog($logName, $logLevel = Logger::WARNING, $logPath=null)
{
if (!empty(self::$all_logs[$logName])) {
unset(self::$all_logs[$logName]);
self::createLogger($logName, $logLevel, $logPath);
}
return self::$all_logs[$logName];
}
}