| 1 |
<?php |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
namespace AWS\CRT; |
| 7 |
use AWS\CRT\CRT; |
| 8 |
|
| 9 |
final class Log { |
| 10 |
const NONE = 0; |
| 11 |
const FATAL = 1; |
| 12 |
const ERROR = 2; |
| 13 |
const WARN = 3; |
| 14 |
const INFO = 4; |
| 15 |
const DEBUG = 5; |
| 16 |
const TRACE = 6; |
| 17 |
|
| 18 |
public static function toStdout() { |
| 19 |
CRT::log_to_stdout(); |
| 20 |
} |
| 21 |
|
| 22 |
public static function toStderr() { |
| 23 |
CRT::log_to_stderr(); |
| 24 |
} |
| 25 |
|
| 26 |
public static function toFile($filename) { |
| 27 |
CRT::log_to_file($filename); |
| 28 |
} |
| 29 |
|
| 30 |
public static function toStream($stream) { |
| 31 |
assert(get_resource_type($stream) == "stream"); |
| 32 |
CRT::log_to_stream($stream); |
| 33 |
} |
| 34 |
|
| 35 |
public static function stop() { |
| 36 |
CRT::log_stop(); |
| 37 |
} |
| 38 |
|
| 39 |
public static function setLogLevel($level) { |
| 40 |
assert($level >= self::NONE && $level <= self::TRACE); |
| 41 |
CRT::log_set_level($level); |
| 42 |
} |
| 43 |
|
| 44 |
public static function log($level, $message) { |
| 45 |
CRT::log_message($level, $message); |
| 46 |
} |
| 47 |
} |