/[drupal]/contributions/modules/trace/drivers/syslog.inc
ViewVC logotype

Contents of /contributions/modules/trace/drivers/syslog.inc

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.3 - (show annotations) (download) (as text)
Mon Jul 7 16:16:14 2008 UTC (16 months, 2 weeks ago) by incanus
Branch: MAIN
CVS Tags: DRUPAL-6--1-0, DRUPAL-6--1-0-ALPHA2, DRUPAL-6--1-0-ALPHA1, HEAD
Changes since 1.2: +2 -2 lines
File MIME type: text/x-php
Imported 6.x branch from SVN development repository.
1 <?php
2 // $Id$
3
4 /**
5 * @file
6 * Output driver for generating system log events for trace messages.
7 */
8
9 //////////////////////////////////////////////////////////////////////////////
10
11 /**
12 * Implements hook_trace().
13 */
14 function trace_syslog_trace($type, $msg, $time = NULL) {
15 $type = sprintf('%-7s', strtoupper($type));
16 $time = _trace_format_timedelta($time);
17 $header = sprintf(TRACE_FORMAT, TRACE_ID, $time, $type) . ' ';
18
19 if (!is_array($msg)) {
20 $output = array($header . $msg);
21 }
22 else {
23 $output = array($header . array_shift($msg));
24 foreach ($msg as $line) {
25 $output[] = str_repeat(' ', strlen($header)) . $line;
26 }
27 }
28
29 static $initialized = FALSE;
30 if (!$initialized) {
31 define_syslog_variables();
32 openlog('drupal', LOG_ODELAY, LOG_USER);
33 $initialized = TRUE;
34 }
35
36 $priority = _trace_syslog_get_priority($type);
37 foreach ($output as $line) {
38 syslog($priority, $line);
39 }
40 }
41
42 function _trace_syslog_get_priority($type) {
43 //return LOG_NOTICE;
44 static $priorities = array(
45 'fatal' => LOG_CRIT,
46 'error' => LOG_ERR,
47 'warn' => LOG_WARNING,
48 'notice' => LOG_NOTICE,
49 'start' => LOG_INFO,
50 'exit' => LOG_INFO,
51 'debug' => LOG_DEBUG,
52 'hook' => LOG_DEBUG,
53 'query' => LOG_DEBUG,
54 'stats' => LOG_DEBUG,
55 );
56 return isset($priorities[$type]) ? $priorities[$type] : LOG_INFO;
57 }
58
59 //////////////////////////////////////////////////////////////////////////////

  ViewVC Help
Powered by ViewVC 1.1.2