$log API variable / WireLog class

Enables creation of logs, logging of events, and management of logs.

Click any linked item for full usage details and examples. Hookable methods are indicated with the icon. In addition to those shown below, the WireLog class also inherits all the methods and properties of: Wire.

Show $var?             Show args?        

Common

NameReturnSummary 
$log->deleteAll()
arrayDelete all log files 
$log->disable(string $name)
selfDisable the given log name temporarily so that save() calls do not record entries during this request 
$log->enable(string $name)
selfEnable a previously disabled log 
$log->error(string $text)
Wire WireLogRecord an error message in the error log (errors.txt) 
$log->exists(string $name)
boolDoes given log name exist? 
$log->message(string $text)
Wire WireLogRecord an informational or 'success' message in the message log (messages.txt) 
$log->path()
stringReturn disk path to log files 
$log->pruneAll(int $days)
arrayPrune all log files to given number of days 
$log->save(string $name, string $text)
boolSave text to a named log
$log->warning(string $text)
Wire WireLogRecord a warning message in the warnings log (warnings.txt) 

Retrieval

NameReturnSummary 
$log->getEntries(string $name)
arrayReturn given number of entries from end of log file, with each entry as an associative array of components 
$log->getFilename(string $name)
stringGet the full filename (including path) for the given log name 
$log->getLines(string $name)
arrayReturn the given number of entries from the end of log file 
$log->getLogs()
arrayReturn array of all logs, sorted by name 
$log->getTotalEntries(string $name)
intGet the total number of entries present in the given log 

Manipulation

NameReturnSummary 
$log->delete(string $name)
boolDelete a log file 
$log->prune(string $name, int $days)
intPrune log file to contain only entries from last [n] days 

Additional methods and properties

In addition to the methods and properties above, WireLog also inherits the methods and properties of these classes:

API reference based on ProcessWire core version 3.0.236

Latest news

  • ProcessWire Weekly #519
    In the 519th issue of ProcessWire Weekly we'll check out a new third party module called RockForms, introduce the latest ProcessWire core updates, and more. Read on!
    Weekly.pw / 20 April 2024
  • ProFields Table Field with Actions support
    This week we have some updates for the ProFields table field (FieldtypeTable). These updates are primarily focused on adding new tools for the editor to facilitate input and management of content in a table field.
    Blog / 12 April 2024
  • Subscribe to weekly ProcessWire news

“We chose ProcessWire because of its excellent architecture, modular extensibility and the internal API. The CMS offers the necessary flexibility and performance for such a complex website like superbude.de. ProcessWire offers options that are only available for larger systems, such as Drupal, and allows a much slimmer development process.” —xport communication GmbH