Logger::logLine PHP Method

logLine() public method

public logLine ( $msg, $shiftfunc = null, $severity = 'info', $trace = null )
    public function logLine($msg, $shiftfunc = null, $severity = 'info', $trace = null)
    {
        $log_file = 'log_' . $severity . '_file';
        if (!isset($this->{$log_file})) {
            $this->openLogFile($severity);
        }
        if ($this->log_output === 'full' && $severity == 'error') {
            if (!$this->header_sent++) {
                fputs($this->{$log_file}, "\n\n" . "============================================================\n" . "{$msg}" . "------------------------------------------------------------\n" . 'Date: ' . date('d-M-Y H:i:s') . "\n");
                foreach ($this->details as $key => $val) {
                    fputs($this->{$log_file}, "{$key}: {$val}\n");
                }
                fputs($this->{$log_file}, "------------------------------------------------------------\n" . " Stack trace\n" . $this->txtBacktrace($shiftfunc, $trace) . "\n");
            } else {
                fputs($this->{$log_file}, $msg);
            }
        } elseif ($this->log_output) {
            fputs($this->{$log_file}, '[' . date('d-M-Y H:i:s') . "] {$msg}");
        } else {
            return;
        }
        fflush($this->{$log_file});
    }

Usage Example

Example #1
0
 public static function log($msg = "", $showCaller = false, $type = Logger::TYPE_DEBUG, $level = 2)
 {
     if (Logger::canLog($type)) {
         switch ($type) {
             case Logger::TYPE_DEBUG:
                 Logger::logLine($msg, DEBUG_LOG_FILE, $showCaller, $level);
                 break;
             case Logger::TYPE_PERFORMANCE:
                 Logger::logLine($msg, PERFORMANCE_LOG_FILE, $showCaller, $level);
                 break;
         }
     }
 }
All Usage Examples Of Logger::logLine