|
| setSendMsg ($b) |
|
| getMessages () |
|
| __construct ($logFile, $logDebug=false) |
|
| emergency ($message, $name="EMERGENCY") |
|
| alert ($message, $name="ALERT") |
|
| critical ($message, $name="CRITICAL") |
|
| error ($message, $name="ERROR") |
|
| warning ($message, $name="WARNING") |
|
| notice ($message, $name="NOTICE") |
|
| info ($message, $name="INFO") |
|
| debug ($message, $name="DEBUG") |
|
| setLogDebug ($logDebug) |
|
| logException (\Throwable $e, $trace=null) |
|
| log ($level, $message) |
|
| shutdown () |
|
| run () |
|
| setWrite ($write) |
|
| setConsoleCallback ($callback) |
|
| addAttachment (\ThreadedLoggerAttachment $attachment) |
|
| removeAttachment (\ThreadedLoggerAttachment $attachment) |
|
| removeAttachments () |
|
| getAttachments () |
|
| getCreatorId () |
|
| getThreadId () |
|
| isJoined () |
|
| isStarted () |
|
| join () |
|
| start (int $options=PTHREADS_INHERIT_ALL) |
|
| chunk ($size, bool $preserve=false) |
|
| count () |
|
| isRunning () |
|
| isTerminated () |
|
| merge ($from, $overwrite=true) |
|
| notify () |
|
| notifyOne () |
|
| offsetGet ($offset) |
|
| offsetSet ($offset, $value) |
|
| offsetExists ($offset) |
|
| offsetUnset ($offset) |
|
| pop () |
|
| run () |
|
| shift () |
|
| synchronized (\Closure $function, $args=null) |
|
| wait ($timeout) |
|
| getRefCount () |
|
| addRef () |
|
| delRef () |
|
| isGarbage () |
|
| emergency ($message) |
|
| alert ($message) |
|
| critical ($message) |
|
| error ($message) |
|
| warning ($message) |
|
| notice ($message) |
|
| info ($message) |
|
| debug ($message) |
|
|
| send ($message, $level, $prefix, $color) |
|
◆ __construct()
__construct |
( |
|
$logFile, |
|
|
|
$logDebug = false |
|
) |
| |
- Parameters
-
string | $logFile | |
bool | $logDebug | |
- Exceptions
-
71 if(static::$logger instanceof MainLogger){
72 throw new \RuntimeException(
"MainLogger has been already created");
74 static::$logger = $this;
78 $this->logStream = new \Threaded;
◆ alert()
alert |
( |
|
$message, |
|
|
|
$name = "ALERT" |
|
) |
| |
- Parameters
-
string | $message | |
string | $name | |
◆ critical()
critical |
( |
|
$message, |
|
|
|
$name = "CRITICAL" |
|
) |
| |
- Parameters
-
string | $message | |
string | $name | |
◆ debug()
debug |
( |
|
$message, |
|
|
|
$name = "DEBUG" |
|
) |
| |
- Parameters
-
string | $message | |
string | $name | |
150 if($this->logDebug ===
false){
◆ emergency()
emergency |
( |
|
$message, |
|
|
|
$name = "EMERGENCY" |
|
) |
| |
- Parameters
-
string | $message | |
string | $name | |
◆ error()
error |
( |
|
$message, |
|
|
|
$name = "ERROR" |
|
) |
| |
- Parameters
-
string | $message | |
string | $name | |
◆ getLogger()
◆ getMessages()
- Returns
- string
59 $this->shouldSendMsg =
"";
60 $this->lastGet = time();
◆ info()
info |
( |
|
$message, |
|
|
|
$name = "INFO" |
|
) |
| |
- Parameters
-
string | $message | |
string | $name | |
◆ log()
- Parameters
-
mixed | $level | |
string | $message | |
Implements Logger.
220 $this->
alert($message);
226 $this->
error($message);
235 $this->
info($message);
238 $this->
debug($message);
◆ logException()
logException |
( |
\Throwable |
$e, |
|
|
|
$trace = null |
|
) |
| |
- Parameters
-
Implements Logger.
169 $trace = $e->getTrace();
171 $errstr = $e->getMessage();
172 $errfile = $e->getFile();
173 $errno = $e->getCode();
174 $errline = $e->getLine();
178 E_ERROR =>
"E_ERROR",
179 E_WARNING =>
"E_WARNING",
180 E_PARSE =>
"E_PARSE",
181 E_NOTICE =>
"E_NOTICE",
182 E_CORE_ERROR =>
"E_CORE_ERROR",
183 E_CORE_WARNING =>
"E_CORE_WARNING",
184 E_COMPILE_ERROR =>
"E_COMPILE_ERROR",
185 E_COMPILE_WARNING =>
"E_COMPILE_WARNING",
186 E_USER_ERROR =>
"E_USER_ERROR",
187 E_USER_WARNING =>
"E_USER_WARNING",
188 E_USER_NOTICE =>
"E_USER_NOTICE",
189 E_STRICT =>
"E_STRICT",
190 E_RECOVERABLE_ERROR =>
"E_RECOVERABLE_ERROR",
191 E_DEPRECATED =>
"E_DEPRECATED",
192 E_USER_DEPRECATED =>
"E_USER_DEPRECATED",
199 $errno = isset($errorConversion[$errno]) ? $errorConversion[$errno] : $errno;
200 if(($pos = strpos($errstr,
"\n")) !==
false){
201 $errstr = substr($errstr, 0, $pos);
203 $errfile = \pocketmine\cleanPath($errfile);
204 $this->
log($type, get_class($e) .
": \"$errstr\" ($errno) in \"$errfile\" at line $errline");
◆ notice()
notice |
( |
|
$message, |
|
|
|
$name = "NOTICE" |
|
) |
| |
- Parameters
-
string | $message | |
string | $name | |
◆ run()
337 $this->
synchronized(
function(){
338 while($this->logStream->count() > 0){
339 $chunk = $this->logStream->shift();
341 $this->logResource = file_put_contents($this->logFile, $chunk, FILE_APPEND);
349 if($this->logStream->count() > 0){
350 while($this->logStream->count() > 0){
351 $chunk = $this->logStream->shift();
353 $this->logResource = file_put_contents($this->logFile, $chunk, FILE_APPEND);
◆ send()
send |
( |
|
$message, |
|
|
|
$level, |
|
|
|
$prefix, |
|
|
|
$color |
|
) |
| |
|
protected |
- Parameters
-
$message | |
$level | |
$prefix | |
$color | |
257 if($thread === null){
258 $threadName =
"Server thread";
259 }elseif($thread instanceof
Thread or $thread instanceof
Worker){
260 $threadName = $thread->getThreadName() .
" thread";
262 $threadName = (new \ReflectionClass($thread))->getShortName() .
" thread";
265 if($this->shouldRecordMsg){
266 if((time() - $this->lastGet) >= 10) $this->shouldRecordMsg =
false;
268 if(strlen($this->shouldSendMsg) >= 10000) $this->shouldSendMsg =
"";
269 $this->shouldSendMsg .= $color .
"|" . $prefix .
"|" . trim($message,
"\r\n") .
"\n";
279 echo $cleanMessage . PHP_EOL;
281 echo $message . PHP_EOL;
284 if(isset($this->consoleCallback)){
285 call_user_func($this->consoleCallback);
289 $this->attachment->call($level, $message);
292 $this->logStream[] = date(
"Y-m-d", $now) .
" " . $cleanMessage .
"\n";
293 if($this->logStream->count() === 1){
294 $this->
synchronized(
function(){
◆ setConsoleCallback()
setConsoleCallback |
( |
|
$callback | ) |
|
- Parameters
-
370 $this->consoleCallback = $callback;
◆ setLogDebug()
◆ setSendMsg()
- Parameters
-
50 $this->shouldRecordMsg = $b;
51 $this->lastGet = time();
◆ setWrite()
◆ shutdown()
◆ warning()
warning |
( |
|
$message, |
|
|
|
$name = "WARNING" |
|
) |
| |
- Parameters
-
string | $message | |
string | $name | |
◆ $logDebug
◆ $logFile
◆ $logger
◆ $logStream
◆ $shouldRecordMsg
◆ $shouldSendMsg
◆ $shutdown
◆ $write
The documentation for this class was generated from the following file:
- src/pocketmine/utils/MainLogger.php