Longman\TelegramBot\TelegramLog::initDebugLog PHP Method

initDebugLog() public static method

Initialize debug log
public static initDebugLog ( string $path ) : Logger
$path string
return Monolog\Logger
    public static function initDebugLog($path)
    {
        if ($path === null || $path === '') {
            throw new TelegramLogException('Empty path for debug log');
        }
        self::initialize();
        self::$debug_log_path = $path;
        return self::$monolog->pushHandler((new StreamHandler(self::$debug_log_path, Logger::DEBUG))->setFormatter(new LineFormatter(null, null, true)));
    }

Usage Example

 public function testDebugStream()
 {
     $file = $this->logfiles['debug'];
     $this->assertFileNotExists($file);
     TelegramLog::initDebugLog($file);
     TelegramLog::debug('my debug');
     $this->assertFileExists($file);
     $this->assertContains('bot_log.DEBUG: my debug', file_get_contents($file));
 }