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 (10 years ago) RSS 2.0 feedNot yet rated by the usersTotal: 445 All time: 6,001 This week: 639Up
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.

Name: khamel <contact>
Classes: 2 packages by
Country: Italy Italy
Age: 34
All time rank: 219485 in Italy Italy
Week rank: 981 Up52 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:0
All time:6,001
This week:639Up