Skip to content

Commit 845f90c

Browse files
committed
namesapce fix
1 parent 0e31ad8 commit 845f90c

File tree

1 file changed

+17
-16
lines changed

1 file changed

+17
-16
lines changed

src/TelegramLog.php

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@
88
* file that was distributed with this source code.
99
*/
1010

11+
namespace Longman\TelegramBot;
12+
1113
use Monolog\Logger;
1214
use Monolog\Handler\StreamHandler;
13-
use TelegramBot\Exception\TelegramLogException;
14-
15-
namespace Longman\TelegramBot;
15+
use Monolog\Formatter\LineFormatter;
16+
use Longman\TelegramBot\Exception\TelegramLogException;
1617

1718
/**
1819
* Class TelegramLog.
@@ -64,13 +65,13 @@ class TelegramLog
6465
*
6566
* @return \Monolog\Logger
6667
*/
67-
public static function initialize(\Monolog\Logger $external_monolog = null)
68+
public static function initialize(Logger $external_monolog = null)
6869
{
6970
if (self::$monolog === null) {
7071
if ($external_monolog !== null) {
7172
self::$monolog = $external_monolog;
7273
} else {
73-
self::$monolog = new \Monolog\Logger('bot_log');
74+
self::$monolog = new Logger('bot_log');
7475
}
7576
}
7677
return self::$monolog;
@@ -85,12 +86,12 @@ public static function initialize(\Monolog\Logger $external_monolog = null)
8586
*/
8687
public static function initErrorLog($path)
8788
{
88-
if (empty($path)) {
89-
throw new \Longman\TelegramBot\Exception\TelegramLogException('Empty path for error log');
89+
if ($path !== '') {
90+
throw new TelegramLogException('Empty path for error log');
9091
}
9192
self::initialize();
9293
self::$error_log_path = $path;
93-
return self::$monolog->pushHandler(new \Monolog\Handler\StreamHandler(self::$error_log_path, \Monolog\Logger::ERROR));
94+
return self::$monolog->pushHandler(new StreamHandler(self::$error_log_path, Logger::ERROR));
9495
}
9596

9697
/**
@@ -102,12 +103,12 @@ public static function initErrorLog($path)
102103
*/
103104
public static function initDebugLog($path)
104105
{
105-
if (empty($path)) {
106-
throw new \Longman\TelegramBot\Exception\TelegramLogException('Empty path for debug log');
106+
if ($path !== '') {
107+
throw new TelegramLogException('Empty path for debug log');
107108
}
108109
self::initialize();
109110
self::$debug_log_path = $path;
110-
return self::$monolog->pushHandler(new \Monolog\Handler\StreamHandler(self::$debug_log_path, \Monolog\Logger::DEBUG));
111+
return self::$monolog->pushHandler(new StreamHandler(self::$debug_log_path, Logger::DEBUG));
111112
}
112113

113114
/**
@@ -120,18 +121,18 @@ public static function initDebugLog($path)
120121
*/
121122
public static function initUpdateLog($path)
122123
{
123-
if (empty($path)) {
124-
throw new \Longman\TelegramBot\Exception\TelegramLogException('Empty path for update log');
124+
if ($path !== '') {
125+
throw new TelegramLogException('Empty path for update log');
125126
}
126127
self::$update_log_path = $path;
127128
if (self::$monolog_update === null) {
128-
self::$monolog_update = new \Monolog\Logger('bot_update_log');
129+
self::$monolog_update = new Logger('bot_update_log');
129130
// Create a formatter
130131
$output = "%message%\n";
131-
$formatter = new \Monolog\Formatter\LineFormatter($output);
132+
$formatter = new LineFormatter($output);
132133

133134
// Update handler
134-
$update_handler = new \Monolog\Handler\StreamHandler(self::$update_log_path, \Monolog\Logger::INFO);
135+
$update_handler = new StreamHandler(self::$update_log_path, Logger::INFO);
135136
$update_handler->setFormatter($formatter);
136137

137138
self::$monolog_update->pushHandler($update_handler);

0 commit comments

Comments
 (0)