Wire::___log PHP Method

___log() public method

Message is saved to a log file in ProcessWire's logs path to a file with the same name as the class, converted to hyphenated lowercase.
public ___log ( string $str = '', array $options = [] ) : WireLog | null
$str string Text to log, or omit to just return the name of the log
$options array Optional extras to include: - url (string): URL to record the with the log entry (default=auto-detect) - name (string): Name of log to use (default=auto-detect)
return WireLog | null
    public function ___log($str = '', array $options = array())
    {
        $log = $this->wire('log');
        if ($log && strlen($str)) {
            if (isset($options['name'])) {
                $name = $options['name'];
                unset($options['name']);
            } else {
                $name = $this->className(array('lowercase' => true));
            }
            $log->save($name, $str, $options);
        }
        return $log;
    }

Usage Example

Ejemplo n.º 1
0
 /**
  * Save to pages activity log, if enabled in config
  * 
  * @param $str
  * @param Page|null Page to log
  * @return WireLog
  * 
  */
 public function log($str, Page $page)
 {
     if (!in_array('pages', $this->wire('config')->logs)) {
         return parent::___log();
     }
     if ($this->wire('process') != 'ProcessPageEdit') {
         $str .= " [From URL: " . $this->wire('input')->url() . "]";
     }
     $options = array('name' => 'pages', 'url' => $page->path);
     return parent::___log($str, $options);
 }
All Usage Examples Of Wire::___log