Welcome to mirror list, hosted at ThFree Co, Russian Federation.

Message.php « Log « modules - github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 96cfd308a4671891da80c18d41f0fb2a0e329c20 (plain)
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
<?php
/**
 * Piwik - Open source web analytics
 * 
 * @link http://piwik.org
 * @license http://www.gnu.org/licenses/gpl-3.0.html Gpl v3 or later
 * @version $Id$
 * 
 * @package Piwik_Log
 * @subpackage Piwik_Log_Message
 */

/**
 * Class used to log a standard message event.
 * 
 * @package Piwik_Log
 * @subpackage Piwik_Log_Message
 */
class Piwik_Log_Message extends Piwik_Log
{
	const ID = 'logger_message';
	function __construct()
	{
		$logToFileFilename = self::ID;
		$logToDatabaseTableName = self::ID;
		$logToDatabaseColumnMapping = null;
		$screenFormatter = new Piwik_Log_Formatter_Message_ScreenFormatter;
		$fileFormatter = new Piwik_Log_Formatter_FileFormatter;
		
		parent::__construct($logToFileFilename, 
							$fileFormatter,
							$screenFormatter,
							$logToDatabaseTableName, 
							$logToDatabaseColumnMapping );
	}
	
	public function log( $message )
	{
		$event = array();
		$event['message'] = $message;
		
		parent::log($event);
	}
}


/**
 * Format a standard message event to be displayed on the screen.
 * The message can be a PHP array or a string.
 * 
 * @package Piwik_Log
 * @subpackage Piwik_Log_Message
 */
class Piwik_Log_Formatter_Message_ScreenFormatter implements Zend_Log_Formatter_Interface
{
	/**
     * Formats data into a single line to be written by the writer.
     *
     * @param  array    $event    event data
     * @return string             formatted line to write to the log
     */
    public function format($event)
    {
    	if(is_array($event['message']))
    	{
    		return "<pre>".var_export($event['message'], true)."</pre>";
    	}
    	else
    	{
    		return $event['message'];
    	}
    }
}