<?php
/**
* This script will return the informations needed by the logs object
* to load the need logs channel. Each channel can define his own
* level mask, context mask and file mask, a message scheme,
* a color set if color is used
* you can apply differents colors tags too:
* html, css, shell
* TODO, color translator keyword => html/shell tag;
* * The following log backend type are available :
* stdout : sent to output
* cache : kept into php vars
* file : kept into a flat file
* datafile: kept into a file (events are serialized/encoded)
* syslog : sent to system log
* dnzb : sent as header, follow NZB directID service api
* db : kept into a database
*
* @author Benjamin Gillissen <hide@address.com>
*
* **************************************************************
Copyright (C) 2007 Benjamin Gillissen
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details at:
http://www.gnu.org/copyleft/gpl.html
* **************************************************************
*/
//first lets define the colors
$COLORS['lvls'] = Array('notice' => 'White',
'debug' => 'Green',
'warning' => 'Yellow',
'info' => '#00BBFF',
'err' => '#BF0000',
'alert' => 'Red',
'crit' => 'Red',
'emerg' => 'Red',
);
$COLORS['info'] = Array('pid' => 'Teal',
'file' => 'Teal',
'line' => 'Purple',
'context' => 'Yellow',
'function' => 'Purple',
'class' => 'Green',
'method' => 'Yellow',
'args' => 'Teal',
'msg' => '',
'ident' => 'Gray',
'time' => '',
);
$fmask = 'ALL,-xmlrpc.inc.php,-xmlrpcs.inc.php';
//TO File as text, one big file for admin
$i='file';
$o['chans'][$i]['inuse'] = TRUE;
$o['chans'][$i]['ident'] = CORE_CONTEXT;
$o['chans'][$i]['fmask'] = $fmask;
$o['chans'][$i]['lmask'] = 'ALL,-DEBUG,-NOTICE';
$o['chans'][$i]['type'] = 'file';
$o['chans'][$i]['conf']['type'] = 'path';
$o['chans'][$i]['conf']['format'] = 'text';
$o['chans'][$i]['conf']['dest'] = PATH_CACHE.'/%ident%.log'; //path to file, %ident% will be replaced by his value
$o['chans'][$i]['conf']['reset'] = FALSE; //do we reset file on open ?
$o['chans'][$i]['conf']['keep'] = TRUE; //do we reset file on open ?
$o['chans'][$i]['msg']['format'] = "%date% @ %hour%:%min%:%sec%,%usec% [%level%][%context%] %file%:%line% => %msg%";
$o['chans'][$i]['msg']['color'] = FALSE;
if ( CORE::sapi() === 'cli' ){
//TO stdout, for cli scripts
$i='std';
$o['chans'][$i]['inuse'] = TRUE;
$o['chans'][$i]['ident'] = CORE_CONTEXT;
$o['chans'][$i]['fmask'] = $fmask;
$o['chans'][$i]['lmask'] = 'ALL,-NOTICE,-DEBUG';
$o['chans'][$i]['type'] = 'stdout';
$o['chans'][$i]['msg']['format'] = "[%level%][%context%] => %msg%";
$o['chans'][$i]['msg']['color'] = FALSE;
} elseif ( CORE_CONTEXT === 'swun-dnzb' ){
//DNZB server, follow dnzb api, send fatal event as header to client.
$i="dnzb";
$o['chans'][$i]['inuse'] = FALSE;
$o['chans'][$i]['fmask'] = 'ALL,-xmlrpc.inc.php,-xmlrpcs.inc.php';
$o['chans'][$i]['lmask'] = 'EMERG,ALERT,CRIT,ERR';
$o['chans'][$i]['ident'] = CORE_CONTEXT;
$o['chans'][$i]['type'] = 'dnzb';
$o['chans'][$i]['msg']['format'] = '%file%:%line% => %msg%';
$o['chans'][$i]['msg']['color'] = FALSE;
} else {
//TO file as data, for webclient, events are serialized, chan is fetched by theme footer, and removed on object __destruct.
$i='debug';
$o['chans'][$i]['inuse'] = TRUE;
$o['chans'][$i]['ident'] = CORE_CONTEXT;
$o['chans'][$i]['fmask'] = 'ALL,-xmlrpc.inc.php,-xmlrpcs.inc.php';
$o['chans'][$i]['lmask'] = 'ALL';
$o['chans'][$i]['type'] = 'file';
$o['chans'][$i]['conf']['type'] = 'uri';
$o['chans'][$i]['conf']['format'] = 'data';
$o['chans'][$i]['conf']['dest'] = 'php://memory';
$o['chans'][$i]['conf']['reset'] = TRUE;
$o['chans'][$i]['conf']['keep'] = FALSE;
$o['chans'][$i]['msg']['format'] = '[%level%][%context%] %file%:%line% => %msg%';
$o['chans'][$i]['msg']['color'] = TRUE;
$o['chans'][$i]['msg']['coltype'] = 'html';
$o['chans'][$i]['msg']['colors'] = $COLORS;
}
/*
//TO SYSLOG, for admins something system wide
$i="syslog";
$o['chans'][$i]['inuse'] = TRUE;
$o['chans'][$i]['lmask'] = 'EMERG,ALERT,CRIT,ERR,INFO';
$o['chans'][$i]['ident'] = CORE_CONTEXT;
$o['chans'][$i]['type'] = 'syslog';
$o['chans'][$i]['msg']['format'] = '[%ident%][%level%]%file%:%line% => %msg%';
$o['chans'][$i]['msg']['color'] = FALSE;
*/
unset($COLORS, $i);
$o['use_init'] = TRUE; //used to catch events raised while log init (stored into mem, flushed at the end of log init to loaded channels )
$o['use_failsave'] = TRUE; //used to output debug when no log channel could be loaded (stdout)
$o['debug_chan'] = 'debug'; //for client (used in theme footers)
//$o['event_chan'] = 2;//for admin (used in event page) not yet in use
return $o;