PHP Classes

BPT_Logger: Log messages to a file

Recommend this page to a friend!
  Info   View files View files (2)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2007-09-21 (9 years ago) RSS 2.0 feedNot yet rated by the usersTotal: 437 This week: 1All time: 5,947 This week: 1,099Up
Version License PHP version Categories
bpt_logger 0.2GNU Lesser Genera...5.0PHP 5, Logging
Description Author

This class can be used to log messages to a file.

It provides functions to append log messages to a files for different error log levels: errors, warnings, information and debug.

The class only appends the messages to the log file if the class log level setting is equal or higher than the log level associated to the log function that is being called.

Picture of khamel
Name: khamel <contact>
Classes: 2 packages by
Country: Italy Italy
Age: 32
All time rank: 216884 in Italy Italy
Week rank: 873 Up36 in Italy Italy Up

*** Use example ***

How it works? It's extremely simple! First of all, you have to include it with


then create it (setting log file name) with

$logger = new Logger('./logs/'.date("Y-m-d").'TestLog.log');

and now you can use it! Call this method to append log information

$logger->append(constant("LOG_INFO"),'Log information');

By default, log level is set to LOG_INFO. Setting log level determinate what information will be write into the log file. In this way, you can use append method to log every operation using different log level (the first method's parameter) but only the information having a log level minus or equal to the Logger's level will be registered. For example

$logger->append(constant("LOG_INFO"),'Log information');
$logger->append(constant("LOG_DEBUG"),'Debug log information');

In this case, only the first information will be logged. You can change logging's verbosity simply setting


where $log_level can assume these values


If you don't want to use custom log level you can call this method instead of append:

$logger->error($msg) //Append $msg with LOG_ERROR level
$logger->warning($msg) //Append $msg with LOG_WARNING level
$logger->info($msg) //Append $msg with LOG_INFO level
$logger->debug($msg) //Append $msg with LOG_DEBUG level
  Files folder image Files  
File Role Description
Plain text file BPT_Logger.class.php Class Main class file
Accessible without login Plain text file README.txt Doc. README

 Version Control Unique User Downloads Download Rankings  
This week:1
All time:5,947
This week:1,099Up