Log class is a basic logging engine you can instantiate inside any of your scripts
to write any text output to a text file.
Log class also provides you with some built in functions to accelerate log
creation and output formatting.
It features automatic dir and file creation and can operate in "one file per log"
or "only one file" modes.
You can easily log formatted date and Log class will automatically track
each log number using a single text file counter.
You can have as many logs as you like in different directories or in the same one,
each one with its individual counter.
Stores the directory specified when you create the class object.
Specifies the log filename. It will be created inside logDir.
Specifies the counter filename. It will be created inside logDir.
Used to create the log Header title, which is a text written in
the first lines of logFile that helps identifying its content.
"oneFile": This is the default value. It indicates the class to use
a single file for all logs. Each time a new Log is created,
contents will be appended at the end of the logFile.
"oneFilePerLog": It indicates the class to use multiple files.
One file per log will be used. Each time a new Log is created
a new autonumerated file will be created in logDir.
Indicates actual log number, read from counter file in logDir and
incremented by one each time a Log is created.
function Log($logDir='log', $logFile='log_', $headerTitle='LOG', $logMode='oneFile', $countFile='counter')
Class constructor. Determines the log dir, log filename, header title and log mode
for the current log proccess. See description of global variables for more details.
This method (or function, as you wish) is used internally and was not meant for
direct use, but it will also work. It writes $logString directly to logFile in logDir.
This is the intended method for using all the time to log content.
$string: String message to write to logFile.
$modifier:"empty": Appends "\n", new line character, to $string.$string functions or "log functions":
"2n": Appends two "\n" to $string.
"3n": Appends three "\n" to $string.
"line": Writes a hardcoded "line" after $string. Actually a "-" line.
"2line": Writes two "line" separators after $string.
"nLine": Writes "\n" and a "line" separator after $string
"2nLine": Writes two "\n" and a "line" separator after $string
"n2Line": Writes "\n" and two "line" separators after $string
When using log function, passed in the $string variable, $modifierfunction get_formatted_date()
is not used.
"f:line": Writes a "line" separator to logFile.
"f:2line": Writes two "line" separators to logFile.
"f:nl": Writes a new line character, "\n", to logFile.
"f:logNumber": Writes actual log number to logFile.
"f:counter": Will use an internal counter which will increment its value
each time it is writen to logFile. Not using any separation from content.
"f:counter.nl": Internal counter followed by "\n" character.
"f:nl.counter": Internal counter preceded by "\n" charecter.
"f:nl.counter.nl": Internal counter between "\n" characters.
Ouputs formatted date.
Example output: 28.08.2005 - 01:14
Originally written by Aidan Lister. Thanks Aidan!
Deletes a directory and all of its content, iterating thru subfolders
(yes, it deletes ALL). It is used by Log class to delete (or clean) logDir and
all of its contents.
It will call rmdirr() method to completely delete logDir and log content.
Just does this: $this->rmdirr($this->logDir);
November 19, 2005 - Banfield, Buenos Aires, Argentina.
Updated on July 27, 2007
Added $countFile parameter to constructor and some new modifiers.
Modified basic functionality description.