8
8
* file that was distributed with this source code.
9
9
*/
10
10
11
+ namespace Longman \TelegramBot ;
12
+
11
13
use Monolog \Logger ;
12
14
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 ;
16
17
17
18
/**
18
19
* Class TelegramLog.
@@ -64,13 +65,13 @@ class TelegramLog
64
65
*
65
66
* @return \Monolog\Logger
66
67
*/
67
- public static function initialize (\ Monolog \ Logger $ external_monolog = null )
68
+ public static function initialize (Logger $ external_monolog = null )
68
69
{
69
70
if (self ::$ monolog === null ) {
70
71
if ($ external_monolog !== null ) {
71
72
self ::$ monolog = $ external_monolog ;
72
73
} else {
73
- self ::$ monolog = new \ Monolog \ Logger ('bot_log ' );
74
+ self ::$ monolog = new Logger ('bot_log ' );
74
75
}
75
76
}
76
77
return self ::$ monolog ;
@@ -85,12 +86,12 @@ public static function initialize(\Monolog\Logger $external_monolog = null)
85
86
*/
86
87
public static function initErrorLog ($ path )
87
88
{
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 ' );
90
91
}
91
92
self ::initialize ();
92
93
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 ));
94
95
}
95
96
96
97
/**
@@ -102,12 +103,12 @@ public static function initErrorLog($path)
102
103
*/
103
104
public static function initDebugLog ($ path )
104
105
{
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 ' );
107
108
}
108
109
self ::initialize ();
109
110
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 ));
111
112
}
112
113
113
114
/**
@@ -120,18 +121,18 @@ public static function initDebugLog($path)
120
121
*/
121
122
public static function initUpdateLog ($ path )
122
123
{
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 ' );
125
126
}
126
127
self ::$ update_log_path = $ path ;
127
128
if (self ::$ monolog_update === null ) {
128
- self ::$ monolog_update = new \ Monolog \ Logger ('bot_update_log ' );
129
+ self ::$ monolog_update = new Logger ('bot_update_log ' );
129
130
// Create a formatter
130
131
$ output = "%message% \n" ;
131
- $ formatter = new \ Monolog \ Formatter \ LineFormatter ($ output );
132
+ $ formatter = new LineFormatter ($ output );
132
133
133
134
// 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 );
135
136
$ update_handler ->setFormatter ($ formatter );
136
137
137
138
self ::$ monolog_update ->pushHandler ($ update_handler );
0 commit comments