public static function runAll($AppName = null) { self::$AppName = $AppName ?: "workerman"; static::$logFile = self::workermanTempFile(self::FILE_TYPE_LOG); static::$pidFile = self::workermanTempFile(self::FILE_TYPE_PID); static::$stdoutFile = self::workermanTempFile(self::FILE_TYPE_STDOUT); parent::runAll(); }
public static function initLogger($name = "enjine", $dir = "/var/log") { if (!is_dir($dir)) { throw new \ErrorException("Logs path does not exist!"); } static::$logger = new Logger($name); static::$logsDir = $dir; $handlers = []; $formatter = new LineFormatter("%datetime%: %level_name% :: %message% | %context% | %extra%\n", "D M j Y, g:i A"); foreach (static::$LOG_LEVELS as $label => $level) { static::$logFile = static::$logsDir . DIRECTORY_SEPARATOR . "{$label}.log"; if (!file_exists(static::$logFile)) { $d = pathinfo(static::$logFile)["dirname"]; if (!is_dir($d)) { mkdir($d, 0664, true); } touch(static::$logFile); } $handlers[$label] = new StreamHandler(static::$logFile, $level); $handlers[$label]->setFormatter($formatter); static::$logger->pushHandler($handlers[$label]); } return static::$logger; }
public function __construct($logFileName = 'common_logs') { static::$logFile = __DIR__ . '/Logs/' . $logFileName . '.txt'; }