/[cvs]/nfo/php/libs/org.netfrag.app/Tracer.php
ViewVC logotype

Diff of /nfo/php/libs/org.netfrag.app/Tracer.php

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

revision 1.1 by joko, Fri Apr 4 02:17:22 2003 UTC revision 1.2 by joko, Sat Apr 5 21:19:38 2003 UTC
# Line 14  Line 14 
14   * $Id$   * $Id$
15   *   *
16   * $Log$   * $Log$
17     * Revision 1.2  2003/04/05 21:19:38  joko
18     * + function event
19     * - function warn
20     * - function info
21     *
22   * Revision 1.1  2003/04/04 02:17:22  joko   * Revision 1.1  2003/04/04 02:17:22  joko
23   * initial commit   * initial commit
24   *   *
# Line 38  Line 43 
43   */   */
44    
45    
46  Exporter::export_symbols('Tracer', array('warn', 'info'));  // lowlevel (just calls 'Dumper')
47  Exporter::export_symbol('Tracer', array('add' => 'trace'));  Exporter::export_symbol('Tracer', array('add' => 'trace'));
48    // highlevel (draws colored boxes)
49    //Exporter::export_symbols('Tracer', array('warn', 'info'));
50    
51    
52  class Tracer {  class Tracer {
53        
   function warn() {  
     $parts = func_get_args();  
     user_error ( join('<br/>', $parts), E_USER_WARNING );  
   }  
     
   function info() {  
     $parts = func_get_args();  
     //print "info: " . Dumper($parts);  
     errors::add_trace($parts);  
   }  
   
54    function box($dom_id = 'errorbox') {    function box($dom_id = 'errorbox') {
55      global $_TRACE;      global $_TRACE;
56    
# Line 89  class Tracer { Line 85  class Tracer {
85            
86    }    }
87        
88      function event($args = array()) {
89    
90        //print "event!!!<br/>";
91        //print Dumper($args);
92    
93        $type = $args[type];
94        $code = $args[code];
95        $error = $args[error];
96        $payload = $args[payload];
97        
98        switch ($type) {
99          case 'full':
100            $output_order = array( 'message', 'component', 'file', 'line', 'level' );
101            break;
102          case 'medium':
103            $output_order = array( 'message', 'level', 'file', 'line' );
104            break;
105          default:
106            $output_order = array( 'message', 'level' );
107            break;
108        }
109    
110        // dispatch color by level
111        if ($code <= 8) {
112          $color = '#eeeeee';
113        } elseif ($code == 512) {
114          $color = 'orange';
115        } elseif ($code == 1024) {
116          $color = 'yellow';
117        } else {
118          $color = 'white';
119        }
120      
121        $buf = array();
122          //print "<hr/><b><font color=\"red\">ERROR:</font></b><br/>";
123          array_push($buf, "<div style=\"background:$color; margin:4px; border:1px black groove; padding:2px;\"><b><font color=\"red\">Event:</font></b> [$code]<br/>");
124          
125            // 1. dump of error object
126            if (is_array($error)) {
127              foreach ($output_order as $key) {
128                array_push($buf, "<b>$key:</b> $error[$key]<br/>");
129              }
130            }
131            // 2. additional payload
132            if (is_array($payload)) {
133              array_push($buf, join('<br/>', $payload) );
134            }
135        
136          array_push($buf, "</div><br/>\n");
137        $out = join("\n", $buf);
138        
139        Tracer::add($out);
140        
141        return $out;
142    
143      }  
144    
145      
146  }  }
147    
148  ?>  ?>

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

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