Alphred
  • Namespace
  • Class
  • Tree
  • Deprecated
  • Todo
  • Download

Namespaces

  • Alphred
  • None

Classes

  • Alfred
  • AppleScript
  • Choose
  • Config
  • Date
  • Dialog
  • Filter
  • Globals
  • i18n
  • Ini
  • Keychain
  • Log
  • Notification
  • Request
  • Result
  • ScriptFilter
  • Text

Interfaces

  • ConfigKeyNotSet
  • Exception
  • FileDoesNotExist
  • InvalidKeychainAccount
  • InvalidScriptFilterArgument
  • InvalidSecurityAction
  • InvalidXMLProperty
  • PasswordExists
  • PasswordNotFound
  • PluginFunctionNotFound
  • RunningOutsideOfAlfred
  • ShouldBeBool
  • TooManyArguments
  • UnknownSecurityException
  • UseOnlyAsStatic

Class Log

Simple static logging functionality that writes to files or STDERR

Namespace: Alphred
Package: Alphred
Since: Class available since 1.0.0
Used by: Alphred::console()
Used by: Alphred::log()
Located at Log.php

Methods summary

public
# file( string $message, integer|string $level = 1, string $filename = 'workflow', boolean|integer $trace = false )

Log a message to a file

Log a message to a file

Parameters

$message
the message to log
$level
the log level
$filename
the filename of the log without an extension
$trace
how far back to trace

Since

1.0.0
public
# console( string $message, string|integer $level = 1, boolean|integer $trace = false )

Log a message to the console (STDERR)

Log a message to the console (STDERR)

Parameters

$message
the message to log
$level
the log level
$trace
how far back to trace

Since

1.0.0
public
# log( string $message, integer|string $level = 1, string $filename = 'workflow', boolean|integer $trace = false )

Log a message to both a file and the console

Log a message to both a file and the console

Parameters

$message
the message to log
$level
the log level
$filename
the filename of the log without an extension
$trace
how far back to trace

Since

1.0.0
private string
# get_log_filename( string $filename )

Gets the full filepath to the log file

Gets the full filepath to the log file

Parameters

$filename
a filename for a log file

Returns

string
the full filepath for a log file

Since

1.0.0
private
# create_log_directory( )

Creates the workflow's data directory if it does not exist.

Creates the workflow's data directory if it does not exist.

Since

1.0.0
private
# check_log( $filename )

Checks to see if the log needs to be rotated

Checks to see if the log needs to be rotated

Since

1.0.0
private
# rotate_log( $filename )

Rotates the log

Rotates the log

Since

1.0.0
private string
# normalize_log_level( integer|string $level )

Normalizes the log level, returning 'INFO' or 1 if invalid

Normalizes the log level, returning 'INFO' or 1 if invalid

Parameters

$level
the level represented as either a string or an integer

Returns

string
the name of the log level

Since

1.0.0
private string
# trace( boolean|integer $depth = false )

Fetches information from a stack trace

Fetches information from a stack trace

Parameters

$depth
How far to do the trace, default is the last

Returns

string
the file and line number of the trace

Since

1.0.0
private boolean
# is_loggable( mixed $level )

Checks if a log level is within a display threshold

Checks if a log level is within a display threshold

Parameters

$level
Either a string or a

Returns

boolean
Whether or not a value is above the logging threshold

Since

1.0.0
private integer
# get_threshold( )

Gets the threshold for log messages

Gets the threshold for log messages

Returns

integer
an integer matching a log level

Since

1.0.0

Todo

Implement exception for bad log level
private string
# date_console( )

Gets the time formatted for a console display log

Gets the time formatted for a console display log

Returns

string
the time as HH:MM:SS

Since

1.0.0
private string
# date_file( )

Gets a datestamp formatted for a file log

Gets a datestamp formatted for a file log

Returns

string
Formatted as YYYY-MM-DD HH:MM:SS

Since

1.0.0

Magic methods summary

Properties summary

public static array $log_levels

An array that contans the valid log levels

An array that contans the valid log levels

Since

1.0.0
# [ 0 => 'DEBUG', 1 => 'INFO', 2 => 'WARNING', 3 => 'ERROR', 4 => 'CRITICAL', ]
Alphred API documentation generated by ApiGen