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    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 461 All time: 6,064 This week: 150Up
Version License PHP version Categories
bpt_logger 0.2GNU Lesser Genera...5.0PHP 5, Logging


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: 39
All time rank: 223086 in Italy Italy
Week rank: 587 Up26 in Italy Italy Up

*** Use example *** How it works? It's extremely simple! First of all, you have to include it with require("logger.class.php"); 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->setLogLevel(constant("LOG_DEBUG")); $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 $logger->setLogLevel($log_level); where $log_level can assume these values LOG_ERROR LOG_WARNING LOG_INFO LOG_DEBUG 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,064
This week:150Up