Coding with SPIP 2.1
SPIP 2.1 Technical Documentation

> > > > spip_log

spip_log

This function is used to record actions out to the log files (generally located in the tmp/log/ directory).

This function accepts 1 or 2 arguments. With one argument, it will write out to just the spip.log file. With two arguments it will write out to both a separate log file and also to the spip.log.

  1. <?php
  2. spip_log($tableau);
  3. spip_log($tableau, 'second_file');
  4. spip_log("adding field $champ into the $table table","my_plugin");
  5. ?>

Download

When a table is passed to the log function, SPIP will write out the output from print_r() into the log file. For each file requested, in this case spip (by default) and second_file, SPIP will create or add the contents of the first argument, but not just anywhere. If the script is run from the private interface, it will write out to "prive_spip.log" or to "prive_second_file.log", otherwise it will write to "spip.log" or "second_file.log".

The configuration file ecrire/inc_version.php defines the maximum size of the log files. When a given log file exceeds this pre-determined file size, it is renamed prive_spip.log.n (n will automatically increment). The number of such files that may exist is also configurable. It is also possible to deactivate the logs by setting one of these specified values to zero within the mes_options.php file.

  1. $GLOBALS['nombre_de_logs'] = 4; // maximum 4 log files
  2. $GLOBALS['taille_des_logs'] = 100; // maximum 100 KB each

Download

There is also a _MAX_LOG constant (set to 100 by default) which specifies the number of entries that each call from a given page may write to a log file. With this default setting, after 100 calls are made to spip_log() from any particular script, the log function will refuse to write any further content for that script.

  • Author :
  • Published :
  • Updated : 30/05/10
  • Translations : English, français