示例#1
0
 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();
 }
示例#2
0
文件: Tools.php 项目: enjine/utils
 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;
 }
示例#3
0
 public function __construct($logFileName = 'common_logs')
 {
     static::$logFile = __DIR__ . '/Logs/' . $logFileName . '.txt';
 }