Overview

Packages

  • AlfredBundler
  • None

Classes

  • AlfredBundler
  • AlfredBundlerIcon
  • AlfredBundlerInternalClass
  • AlfredBundlerLogger
  • Overview
  • Package
  • Class
  • Tree

Class AlfredBundlerLogger

Simple logging functionality that writes to files or STDERR

Usage: just create a single object and reuse it solely. Initialize the object with a full path to the log file (no log extension)

This class was written to be part of the PHP implementation of the Alfred Bundler for the bundler's internal logging requirements. However its functionality is also made available to any workflow author implementing the bundler.

While you can use this class without going through the bundler, it is easier just to use the logging functionality indirectly via the bundler object.

Package: AlfredBundler
Copyright: The Alfred Bundler Team 2014
License: MIT
Since: Class available since Taurus 1
See: AlfredBundlerInternalClass::$log
See: AlfredBundlerInternalClass::debug()
See: AlfredBundlerInternalClass::info()
See: AlfredBundlerInternalClass::warning()
See: AlfredBundlerInternalClass::error()
See: AlfredBundlerInternalClass::critical()
See: AlfredBundlerInternalClass::console()
Located at AlfredBundlerLogger.php
Methods summary
public
# __construct( string $log, string $destination = 'file' )

Sets variables and ini settings to ensure there are no errors

Sets variables and ini settings to ensure there are no errors

Parameters

$log
string
$log filename to use as a log
$destination
string
$destination = 'file' default destination for messages

Since

Taurus 1
public
# log( string $message, mixed $level = 'INFO', string $destination = '', mixed $trace = 0 )

Logs a message to either a file or STDERR

Logs a message to either a file or STDERR

After initializing the log object, this should be the only method with which you interact.

While you could use this separate from the bundler itself, it is easier to use the logging functionality from the bundler object.

Parameters

$message
string
$message message to log
$level
mixed
$level either int or string of log level
$destination
string
$destination where the message should appear: valid options: 'file', 'console', 'both'
$trace

Since

Taurus 1

See

AlfredBundlerInternalClass::log <code> $log = new AlfredBundlerLogger( '/full/path/to/mylog' ); $log->log( 'Write this to a file', 'INFO' ); $log->log( 'Warning message to console', 2, 'console' ); $log->log( 'This message will go to both the console and the log', 3, 'both'); </code>
public string
# normalizeLogLevel( mixed $level )

Ensures that the log level is valid

Ensures that the log level is valid

Parameters

$level
mixed
$level either an int or a string denoting log level

Returns

string
log level as string

Since

Taurus 1
public
# logConsole( string $message )

Writes a message to the console (STDERR)

Writes a message to the console (STDERR)

Parameters

$message
string
$message message to log

Since

Taurus 1
public
# logFile( string $message )

Writes message to log file

Writes message to log file

Parameters

$message
string
$message message to log

Since

Taurus 1
Properties summary
public string $log
#

Log file

Log file

Full path to log file with no extension; set by user at instantiation

Since

Taurus 1
protected array $logLevels
#

An array of log levels (int => string )

An array of log levels (int => string )

0 => 'DEBUG' 1 => 'INFO' 2 => 'WARNING' 3 => 'ERROR' 4 => 'CRITICAL'

Since

Taurus 1
Alfred Bundler API documentation generated by ApiGen 2.8.0