wiki:Logs

TOC?

Introduction

This page serves to keep info on the log system of the BW Rox codebase in one place. You should be able to find general knowledge on logs and logging as well as code examples of how to do logging.

Purpose

Logging has two purposes for us:

# Providing help with debugging # Providing a blueprint of what happened in cases of doubt

This means mainly logging three things: changes to data, access to data, and errors and problems.

# Changes: these should be logged so we can see how things change and who changed them # Access: in case of access to private or sensitive data, it's good to log access so we know how it's accessed and by whom # Errors: whenever unexpected errors happen, they should always be logged. Sometimes the software should do it, other times it should just fall through to PHP/Apache

Under no circumstances should private or sensitive data be logged! If a member updates name or phonenumber, the update itself should be logged, but not the changed data (either new or old). The logs are readable by many people and controlling access to them is much harder than controlling access to the data.

Files

Modules

The module handling the log is  http://bevolunteer.org/trac/browser/trunk/modules/log/lib/log.lib.php - it doesn't contain much apart from a method to write log strings to the log. If you're developing code for BW Rox you almost certainly do not need to use this module directly. See below for how to use the log functions through BW Rox.

Rox classes

All major rox classes inherit from  RoxComponentBase - and this class defines some wrapper functions for the log. Specifically:

  • RoxComponentBase::getLog()
  • RoxComponentBase::logWrite($string, $type = 'Log')

The first method returns an instance of the log, the second simply writes to the log. Whenever you need to write a log string to the log, just use the second method. Don't get the log first, don't use MOD_log::get() or anything like. Just use $this->logWrite('info here', 'type here')

Physical storage

Rox log files are normally stored in the database - either in the main database (trunk) or in the ARCH database (alpha and production). The setting that determines where is $_SYSHCVOLARCH_DB? - a global variable (something that should be changed).

Examples

To record info about a member changing location:

$this->logWrite("The Member with the Id: {$IdMember} changed his location to Geo-Id: {$geonameid}" "Members");

To log the deletion of a profile translation:

$this->logWrite("Deleting translation for language {$lang_id} {$count} translations deleted", "Update profile");

Other logs

Application log files (from Apache, MySQL and PHP) are store in /home/bwrox/logs on the production server. On the test server they are stored in /var/log/

Logs:

  • Apache: /home/bwrox/logs/www.bewelcome.org-YYYY-MM-access.log and /home/bwrox/logs/www.bewelcome.org-error.log
  • PHP: /home/bwrox/logs/php_errors.log
  • MySQL: /home/bwrox/logs/mysql/mysql.log
  • Exception logs: /home/bwrox/logs/exception.log

Legal stuff

This paragraph needs some expertise and need to be completed

BeWelcome/BeVolunteer is forbidden to communitate these logs to any third part

In case of official request from french autorities, these logs can be communicated to french police.