\KLogger
Class documentation
Synopsis
class KLogger
{
- // constants
- const EMERG = 0;
- const ALERT = 1;
- const CRIT = 2;
- const ERR = 3;
- const WARN = 4;
- const NOTICE = 5;
- const INFO = 6;
- const DEBUG = 7;
- const OFF = 8;
- const FATAL = 2;
- const STATUS_LOG_OPEN = 1;
- const STATUS_OPEN_FAILED = 2;
- const STATUS_LOG_CLOSED = 3;
- // members
- private integer $_logStatus = self::STATUS_LOG_CLOSED;
- private array $_messageQueue = ;
- private $_logFilePath = NULL;
- private integer $_severityThreshold = self::INFO;
- private $_fileHandle = NULL;
- private array $_messages = ;
- private static integer $_defaultSeverity = self::DEBUG;
- private static string $_dateFormat = 'Y-m-d G:i:s';
- private static integer $_defaultPermissions = 0777;
- private static array $instances = ;
- // methods
- public static KLogger instance()
- public void __construct()
- public void __destruct()
- public void logDebug()
- public string getMessage()
- public array getMessages()
- public void clearMessages()
- public static void setDateFormat()
- public void logInfo()
- public void logNotice()
- public void logWarn()
- public void logError()
- public void logFatal()
- public void logAlert()
- public void logCrit()
- public void logEmerg()
- public void log()
- public void writeFreeFormLine()
- private void _getTimeLine()
Constants
Name | Value |
---|---|
EMERG | 0 |
ALERT | 1 |
CRIT | 2 |
ERR | 3 |
WARN | 4 |
NOTICE | 5 |
INFO | 6 |
DEBUG | 7 |
OFF | 8 |
FATAL | 2 |
STATUS_LOG_OPEN | 1 |
STATUS_OPEN_FAILED | 2 |
STATUS_LOG_CLOSED | 3 |
Members
private
- $_dateFormat
—
string
Valid PHP date() format string for log timestamps - $_defaultPermissions
—
integer
Octal notation for default permissions of the log file - $_defaultSeverity
—
integer
Default severity of log messages, if not specified - $_fileHandle
—
resource
This holds the file handle for this instance's log file - $_logFilePath
—
string
Path to the log file - $_logStatus
—
integer
Current status of the log file - $_messageQueue
—
array
Holds messages generated by the class - $_messages
—
array
Standard messages produced by the class. Can be modified for il8n - $_severityThreshold
—
integer
Current minimum logging threshold - $instances
—
array
Array of KLogger instances, part of Singleton pattern
Methods
private
public
- __construct() — Class constructor
- __destruct() — Class destructor
- clearMessages() — Empties the message queue
- getMessage() — Returns (and removes) the last message from the queue.
- getMessages() — Returns the entire message queue (leaving it intact)
- instance() — Partially implements the Singleton pattern. Each $logDirectory gets one instance.
- log() — Writes a $line to the log with the given severity
- logAlert() — Writes a $line to the log with a severity level of ALERT.
- logCrit() — Writes a $line to the log with a severity level of CRIT.
- logDebug() — Writes a $line to the log with a severity level of DEBUG
- logEmerg() — Writes a $line to the log with a severity level of EMERG.
- logError() — Writes a $line to the log with a severity level of ERR. Most likely used with E_RECOVERABLE_ERROR
- logFatal() — Writes a $line to the log with a severity level of FATAL. Generally corresponds to E_ERROR, E_USER_ERROR, E_CORE_ERROR, or E_COMPILE_ERROR
- logInfo() — Writes a $line to the log with a severity level of INFO. Any information can be used here, or it could be used with E_STRICT errors
- logNotice() — Writes a $line to the log with a severity level of NOTICE. Generally corresponds to E_STRICT, E_NOTICE, or E_USER_NOTICE errors
- logWarn() — Writes a $line to the log with a severity level of WARN. Generally corresponds to E_WARNING, E_USER_WARNING, E_CORE_WARNING, or E_COMPILE_WARNING
- setDateFormat() — Sets the date format used by all instances of KLogger
- writeFreeFormLine() — Writes a line to the log without prepending a status or timestamp