PHP Classes

Easy Logging: Log activity to a database

Recommend this page to a friend!
  Info   Screenshots Screenshots   View files View files (10)   DownloadInstall with Composer Download .zip   Reputation   Support forum (1)   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 2,170 This week: 1All time: 1,804 This week: 560Up
Version License PHP version Categories
easy-logging 1.2GNU General Publi...3.0Databases, Logging
Description 

Author

This class can be used to log activity to a database.

It can add activity entries to a log database table. It logs the activity prority level and class, the remote user identifier (if logged) and its computer IP address.

Optionally it can send e-mail about the activities being logged to a given e-mail address.

It can also display log entries as an HTML table.

Picture of Alejandro U. Alvarez
Name: Alejandro U. Alvarez <contact>
Classes: 1 package by
Country: Spain Spain
Age: 32
All time rank: 140730 in Spain Spain
Week rank: 416 Up14 in Spain Spain Up

Details

PHP logging class: Visit: http://urbanoalvarez.es/blog/2008/03/21/php-logging-class/ For full support Developed by Alejandro U Alvarez. Released under the GPL Licence (Free for personal and commercial use, but please, provdide link) Features This are the things the logging class will do: * Store different security levels (Low, Medium, and High) * Get the real visitor's IP for every log entry * Allow several optional parameters, such as message, priority, page... * Easily translated into other languages * TABLE_LOGS.sql.txt - This file creates the table 'log' And this is a screenshot of the log page in action (Or go to the sample page and take a look) Screenshot of log Class files and code: The following files are the really important files: * log.class.php - This file contains the logging functions. * database.php - This file handles database connection and queries. * config.php - This file defines the configuration constants used for database queries. You should only edit this file. * logInit.php - This file includes all necessary files and initializes the classes storing them in the appropriate objects Also, for the example, there are two other files: 'log.php' and 'test.php'. The log.php file shows a sample log, and the test.php shows a sample usage page. Log in use: I've set up a test page and a log page. In the test page there are several "common" stuff that you would normally log (A login form, an edit form, and a contact form) I would recommend that you check those out, in any order you like, and experiment with the different options you'll see in the test page Usage: The usage of this logging class is VERY very simple, First of all download the zip with the needed files. Then you must fill in all the variables in the config.php page. Once all is configured, upload it to your server, and insert the following code in all the pages you will like to log activity: < ?php //Initialize logging clases include('logInit.php'); // ?> This is the initialization of the logging object and all other needed stuff. The logging function is: < ?php $log->logg('page','message','priority','class','mail'); ?> Parameters explanation: * Page: This is the page where the log is placed. Set to 1 and it will be automatically detected. * Message: This is the message you want to have the log store. You can have some preset messages which are stored in the log.class.php file. Set to 1 to have a preset message stored. * Priority: This is the priority or Importance of the log entry. Values can be: High,Medium,Low. * Class: This is the class you want the log entry to have. Values are: Red, Danger, Yellow, Green, and Blue. * Mail: This setting can be yes or no. If it is not specified it will be set to "no". You can edit the list of pre-set important pages in the file log.class.php, which is strongly recommended. If you improve this script, or you find any bugs, report them using the comments please! And remember, for any doubt or problem you have with the usage of this class, comment here and leave an email in the field email so I can answer you! http://urbanoalvarez.es/blog/2008/03/21/php-logging-class/

Screenshots  
  • log_screenshot.jpg
  Files folder image Files  
File Role Description
Plain text file config.php Conf. Configuration file
Plain text file database.php Class Database connection handler
Plain text file db_table.sql.txt Data SQL code to create necessary table
Plain text file getip.php Aux. Gets real visitor's ip
Plain text file log.class.php Class Logging methods class
Plain text file log.php Example Sample log file
Plain text file logInit.php Aux. Log initializer, include in all pages
Plain text file readme.txt Doc. Readme file, usage, features, installation...
Plain text file styles.css Data CSS styles for the log
Plain text file test.php Example Test page, to see sample log calls

 Version Control Unique User Downloads Download Rankings  
 0%
Total:2,170
This week:1
All time:1,804
This week:560Up
User Comments (1)