Gumbo_Log_Message
Variables
- $_file
- $_formatted
- $_left_delimeter
- $_lines
- $_line_end
- $_locked
- $_message
- $_right_delimeter
- $_separator
- $_type
Methods
Abstract Log Message
A Log Message contains information that should be logged into the Log file. A Message can contain a single line of information, or span multiple lines. It depends on the type of Message. Every line is separated into sections, each section contain an actual piece of data. The information is written to the Message file, either directly or through a Log class. The file is appended, placing the formatted message at the end of the file.
The Abstract Message contains a standard formatting implementation. This will format a string based on the contents of the Message. The format method will loop through each line, appending a string variable with the details. The line is formatted started with the 'Left Delimeter'. Each line is parsed into sections, each section appended to the string, separated by the 'Separator' character string. The line ends by placing the 'Right Delimeter' before the 'Line End' string. Once all lines have been formatted, the 'Message' text is set.
To add Lines to a message, call the addLine() method with arguments that represent the sections of the line. For example, if producing a Log Message with the following format: 'date|id|name', simply call addLine() as:
$mess->addLine ($date, $id, $name);
Log Files will contain different formats. In order to format a Log File to a specific format, simply extend the Abstract Message class, writing the rules and defaults in the Constructor (see Gumbo_Log_Message_Generic). If special formatting is required, simply write a custom 'format' implementation. If the default values should not be changed, simply 'lock' the message. (This does not apply to adding lines).
It is important to define the Log File inside the Message class. An Email Log Message should write to an 'email.log' file, while an Access Log Message should write to an 'access.log' file. This allows the program to simply create a new Log Message without having to define the file to write to. By creating multiple Log Messages with specific formatting rules, the program would only need to instantiate the Log Message class, add the necessary details and send to the Log class.
Author(s): |
Michael Luster <mluster79@yahoo.com> |
License: | New BSD License |
Copyright: | Copyright (c) 2007, iBayou, Michael Luster |
Link: | http://sourceforge.net/projects/phpgumbo |
Version: | 0.0.1 |
Implements interfaces:
Child classes:
Class Variables
Class Methods
Adds a line to the log message
The arguments supplied will be the data that is represented in the printed string in the message. Each argument will be a different piece of data, which will be separated by the Separator character string when the message is formatted.
- postcondition:
!isFormatted()
[ Top ]isFormatted() - postcondition:
isset($_message) - precondition:
!isFormatted()
[ Top ]isLocked()
[ Top ]public void setFile ( string $file ) [line 262]Sets the log file
Parameter(s):
- (string) $file :: file name (absolute path)
- precondition:
!isLocked() - throws:
Gumbo_Exception
[ Top ]protected void setFormatted ( bool $val ) [line 242]Sets if the message has been formatted
Parameter(s):
- (bool) $val
- throws:
Gumbo_Exception
[ Top ]public void setLeftDelimeter ( string $del ) [line 336]Sets the left delimeter
Parameter(s):
- (string) $del
- throws:
Gumbo_Exception - postcondition:
!isFormatted() - precondition:
!isLocked()
[ Top ]public void setLineEnd ( string $end ) [line 286]Sets the line end string
Parameter(s):
- (string) $end
- throws:
Gumbo_Exception - postcondition:
!isFormatted() - precondition:
!isLocked()
[ Top ]protected void setMessage ( string $mess ) [line 223]Sets the message string
Parameter(s):
- (string) $mess
- throws:
Gumbo_Exception
[ Top ]public void setRightDelimeter ( string $del ) [line 361]Sets the right delimeter
Parameter(s):
- (string) $del
- throws:
Gumbo_Exception - postcondition:
!isFormatted() - precondition:
!isLocked()
[ Top ]public void setSeparator ( string $sep ) [line 311]Sets the separator between elements
Parameter(s):
- (string) $sep
- throws:
Gumbo_Exception - postcondition:
!isFormatted() - precondition:
!isLocked()
[ Top ]public void setType ( string $type ) [line 201]Sets the message type
Parameter(s):
- (string) $type
- precondition:
!isLocked() - throws:
Gumbo_Exception
[ Top ]