KO3_FirePHP /classes/firephp/log/console.php

Language PHP Lines 153
MD5 Hash e3287aad0a1f453f2447eb9469f3647d Estimated Cost $2,484 (why?)
Repository git://github.com/jerfowler/KO3_FirePHP.git View Raw File
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
<?php defined('SYSPATH') or die('No direct script access.');
/**
 * FirePHP log writer.
 */

class FirePHP_Log_Console extends Kohana_Log_Writer {
    protected $_firephp;
    // List of excluded types
    protected $_excluded;
    // Format for console entries
    protected $_format;

    /**
     * Creates a new FirePHP logger.
     *
     * @param   string  config array
     * @return  void
     */
    public function __construct(array $config=NULL) {
	$this->_firephp = FirePHP_Profiler::instance();
	if (isset($config)) $this->_firephp->set_config($config);
	$this->_format = $this->_firephp->get_config('log.console.format', 'time --- type: body');
	$this->_excluded = $this->_firephp->get_config('log.console.exclude');
    }

    /**
     * Writes each of the messages to FirePHP
     *
     * @param   array   messages
     * @return  void
     */
    public function write(array $messages) {
	// Set the log line format
	$format = $this->_format;
	foreach ($messages as $message) { // Write each message into the log file
	    if (isset($this->_excluded) AND in_array($message['type'], $this->_excluded)) continue;
	    switch($message['type'])
	    {
		/**
		* Firebug LOG level
		*/
		case 'FirePHP::LOG':
		    if (is_array($message['body']))
		    {
			$label = Arr::path($message, 'body.label', '');
			$object = Arr::path($message, 'body.object', $message['body']);
			$this->_firephp->log($object, $label);
		    } 
		    else
		    {
			$this->_firephp->log(strtr($format, $message));
		    }
		    break;
		/**
		* Firebug INFO level
		*/
		case 'FirePHP::INFO':
		    if (is_array($message['body']))
		    {
			$label = Arr::path($message, 'body.label', '');
			$object = Arr::path($message, 'body.object', $message['body']);
			$this->_firephp->info($object, $label);
		    }
		    else
		    {
			$this->_firephp->info(strtr($format, $message));
		    }
		    break;
		/**
		* Firebug WARN level
		*/
		case 'FirePHP::WARN':
		    if (is_array($message['body']))
		    {
			$label = Arr::path($message, 'body.label', '');
			$object = Arr::path($message, 'body.object', $message['body']);
			$this->_firephp->warn($object, $label);
		    }
		    else
		    {
			$this->_firephp->warn(strtr($format, $message));
		    }
		    break;
		/**
		* Firebug ERROR level
		*/
		case 'FirePHP::ERROR':
		    if (is_array($message['body']))
		    {
			$label = Arr::path($message, 'body.label', '');
			$object = Arr::path($message, 'body.object', $message['body']);
			$this->_firephp->error($object, $label);
		    }
		    else
		    {
			$this->_firephp->error(strtr($format, $message));
		    }
		    break;
		/**
		* Dumps a variable to firebug's server panel
		*/
		case 'FirePHP::DUMP':
		    if (is_array($message['body']))
		    {
			$key = Arr::path($message, 'body.key', '');
			$variable = Arr::path($message, 'body.variable', $message['body']);
			$this->_firephp->dump($key, $variable);
		    }
		    else
		    {
			$this->_firephp->log(strtr($format, $message));
		    }
		    break;
		/**
		* Displays a stack trace in firebug console
		*/
		case 'FirePHP::TRACE';
		    $this->_firephp->trace(strtr($format, $message));
		    break;
		/**
		* Displays an table in firebug console
		*/
		case 'FirePHP::TABLE':
		    if (is_array($message['body']))
		    {
			$label = Arr::path($message, 'body.label', '');
			$table = Arr::path($message, 'body.table', '');
			$this->_firephp->table($label, $table);
		    }
		    else
		    {
			$this->_firephp->log(strtr($format, $message));
		    }
		    break;
		/**
		* Starts a group in firebug console
		*/
		case 'FirePHP::GROUP_START';
		    $this->_firephp->group(strtr($format, $message));
		    break;
		/**
		* Ends a group in firebug console
		*/
		case 'FirePHP::GROUP_END';
		    $this->_firephp->groupEnd();
		    break;
		default:
		    $this->_firephp->log(strtr($format, $message));
	    }
	}
    }

} // End Kohana_Log_File
Back to Top