/[cvs]/nfo/php/libs/org.netfrag.glib/Class/Logger.php
ViewVC logotype

Diff of /nfo/php/libs/org.netfrag.glib/Class/Logger.php

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by joko, Mon Mar 3 21:26:43 2003 UTC revision 1.11 by joko, Fri Mar 28 06:44:20 2003 UTC
# Line 1  Line 1 
1  <?  <?
2  // ---------------------------------------------------------------------------  /**
3  //  $Id$   * This file contains the Class::Logger class.
4  // ---------------------------------------------------------------------------   *
5  //  $Log$   * @author Andreas Motl <andreas.motl@ilo.de>
6  //  Revision 1.1  2003/03/03 21:26:43  joko   * @package org.netfrag.glib
7  //  refactored from DesignPattern::Logger   * @name Class::Logger
8  //   *
9  //  Revision 1.4  2003/02/13 00:43:41  joko   */
10  //  + logfile name now can get passed via defined constant  
11  //  
12  //  Revision 1.3  2003/02/09 17:14:49  joko  /**
13  //  + now able to redirect errors raised by PEAR to logfile   * <b>Cvs-Log:</b>
14  //   *
15  //  Revision 1.2  2003/02/03 14:47:49  joko   * <pre>
16  //  + some code from DesignPattern::Bridge   *
17  //   *  $Id$
18  //  Revision 1.1  2003/02/03 03:33:48  joko   *
19  //  + initial commit   *  $Log$
20  //   *  Revision 1.11  2003/03/28 06:44:20  joko
21  // ---------------------------------------------------------------------------   *  VERBOSE mode
22     *
23     *  Revision 1.10  2003/03/28 03:04:26  joko
24     *  enhanced conditions for debugging
25     *
26     *  Revision 1.9  2003/03/27 15:59:55  joko
27     *  enhanced 'function log'
28     *
29     *  Revision 1.8  2003/03/11 02:23:02  joko
30     *  + fixed metadata for phpDocumentor
31     *
32     *  Revision 1.7  2003/03/11 02:14:23  joko
33     *  + fixed metadata for phpDocumentor
34     *
35     *  Revision 1.6  2003/03/11 02:04:36  joko
36     *  + fixed metadata for phpDocumentor
37     *
38     *  Revision 1.5  2003/03/11 01:42:59  joko
39     *  + fixed metadata for phpDocumentor
40     *
41     *  Revision 1.4  2003/03/11 01:22:24  joko
42     *  + fixed metadata for phpDocumentor
43     *
44     *  Revision 1.3  2003/03/11 01:12:53  joko
45     *  + fixed metadata for phpDocumentor
46     *
47     *  Revision 1.2  2003/03/05 18:54:43  joko
48     *  updated docu - phpDocumentor is very strict about its 'blocks'...
49     *
50     *  Revision 1.1  2003/03/03 21:26:43  joko
51     *  refactored from DesignPattern::Logger
52     *
53     *  Revision 1.4  2003/02/13 00:43:41  joko
54     *  + logfile name now can get passed via defined constant
55     *
56     *  Revision 1.3  2003/02/09 17:14:49  joko
57     *  + now able to redirect errors raised by PEAR to logfile
58     *
59     *  Revision 1.2  2003/02/03 14:47:49  joko
60     *  + some code from DesignPattern::Bridge
61     *
62     *  Revision 1.1  2003/02/03 03:33:48  joko
63     *  + initial commit
64     *
65     * </pre>
66     *
67     */
68    
69    
70    /**
71     * This requires Class::Abstract as a base class
72     *
73     */
74    php::loadModule('Class::Abstract');
75    
76    
77  php::loadModule('Class::Abstract');  /**
78     * --- Class::Inner
79     *
80     * @author Andreas Motl <andreas.motl@ilo.de>
81     * @copyright (c) 2003 - All Rights reserved.
82     * @license GNU LGPL (GNU Lesser General Public License)
83     *
84     * @link http://www.netfrag.org/~joko/
85     * @link http://www.gnu.org/licenses/lgpl.txt
86     *
87     * @package org.netfrag.glib
88     * @subpackage Class
89     * @name Class::Logger
90     *
91     *
92     */
93  class Class_Logger extends Class_Abstract {  class Class_Logger extends Class_Abstract {
94    
95    var $logger;    var $logger;
# Line 42  class Class_Logger extends Class_Abstrac Line 109  class Class_Logger extends Class_Abstrac
109      $this->_init_logger($logfile, 1);      $this->_init_logger($logfile, 1);
110    }    }
111    
112    
113    // TODO: split by loglevel here to make seperated logfiles possible (debug, normal, errors)    // TODO: split by loglevel here to make seperated logfiles possible (debug, normal, errors)
114    // TODO: optional: transmit logging messages via tcp - don't write them to disk (a handler for PEAR::Log)    // TODO: optional: transmit logging messages via tcp - don't write them to disk (a handler for PEAR::Log)
115    function log($msg, $level = PEAR_LOG_DEBUG) {    function log($msg, $level = PEAR_LOG_DEBUG) {
# Line 52  class Class_Logger extends Class_Abstrac Line 120  class Class_Logger extends Class_Abstrac
120        // TODO: how are these type of errors handled?        // TODO: how are these type of errors handled?
121        //print "error-message: $msg<br>";        //print "error-message: $msg<br>";
122      }      }
123        
124        // TODO: modify this condition: make it more flexible: introduce '$this->ERRORS_STDOUT' or s.th.l.th.
125        //$debug_condition = $this->DEBUG || $level <= PEAR_LOG_WARNING;
126        $debug_condition = $this->DEBUG;
127        //$error_condition = $level <= PEAR_LOG_ERR;
128        $error_condition = $level <= PEAR_LOG_WARNING;
129        
130        $label = 'Unknown'; $color = 'black';
131        if ($debug_condition) { $label = 'Debug'; $color = 'darkgreen'; }
132        if ($error_condition) { $label = 'Error'; $color = 'red'; }
133        
134        $stdout_condition = constants::get('VERBOSE') && $level && ($debug_condition || $error_condition);
135        if ($stdout_condition) {
136          // TODO: what now?
137          //user_error($msg);
138          //print "<div><span style=\"color: $color;\"><b>$label</b></span>[$level]: <i>$msg</i></div>";
139          $style = html_style("text/css", '.boxlabel_red { color: red; font-weight:bold; }');
140          $box = html_span();
141          //$box->set_style("border-bottom: 1px solid black;");
142          $box->add( html_span('boxlabel_red', $label), "[$level]: $msg", html_br() );
143          print $style->render();
144          print $box->render();
145        }
146        
147    }    }
148    
149    function _init_logger($logfile, $enable = 0) {    function _init_logger($logfile, $enable = 0) {

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.11

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed