reborn /heart/reborn/src/Reborn/Cores/Log.php

Language PHP Lines 166
MD5 Hash 0ffe7a77128e9ca293269e19e9e37814 Estimated Cost $1,212 (why?)
Repository https://bitbucket.org/yelinaung/reborn.git View Raw File View Project SPDX
  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
154
155
156
157
158
159
160
161
162
163
164
165
<?php

namespace Reborn\Cores;

use Monolog\Logger;
use Monolog\Handler\StreamHandler;

/**
 * Log Class for Reborn CMS
 *
 * This class is really adapter only between Monolog and Reborn CMS.
 * Supported logging methods are -
 *  -- debug
 *  -- info
 *  -- notice
 *  -- warning
 *  -- error
 *  -- critical
 *  -- alert
 *  -- emergency
 * You can see defination for above methods at monolog documentation.
 *
 * @package cores
 * @author Reborn CMS Development Team
 **/
class Log
{

	/**
	 * Variable for Log config items
	 *
	 * @var array
	 **/
	public $configs = array();

	#public $instance = null;

	/**
	 * Variable for monolog object
	 *
	 * @var object
	 **/
	public $logger = null;

	/**
	 * Default constructor method for log object
	 * You can pass configs values shch as
	 *
	 * <code>
	 * array(
	 * 	'path' => 'public/storages/applogs/',
	 * 	'file_name' => 'mylog-'Date(Y-m-d),
	 * 	'ext' => '.txt'
	 * );
	 * </code>
	 *
	 * @param string $name
	 * @param array $configs
	 * @return void
	 **/
	public function __construct($name = 'rebornCMSLog', $configs = array())
	{
		$defaultConfigs = Config::get('app.log');

		// Merge Default configs and given configs
		$this->configs = array_merge($defaultConfigs, $configs);

		$this->logger = new Logger($name);

		$fullpath = $this->configs['path'].$this->configs['file_name'].$this->configs['ext'];

		$this->logger->pushHandler(new StreamHandler($fullpath, Logger::DEBUG));
	}

	/**
	 * Get the Logger Object
	 *
	 * @return object
	 */
	public function getLogger()
	{
		return $this->logger;
	}

	/**
	 * Debug Log method adpater
	 *
	 * @param mixed $text Message you want to logging
	 */
	public function debug($text)
	{
		$this->logger->addDebug($text);
	}

	/**
	 * Info Log method adpater
	 *
	 * @param mixed $text Message you want to logging
	 */
	public function info($text)
	{
		$this->logger->addInfo($text);
	}

	/**
	 * Notice Log method adpater
	 *
	 * @param mixed $text Message you want to logging
	 */
	public function notice($text)
	{
		$this->logger->addNotice($text);
	}

	/**
	 * Warning Log method adpater
	 *
	 * @param mixed $text Message you want to logging
	 */
	public function warning($text)
	{
		$this->logger->addWarning($text);
	}

	/**
	 * Error Log method adpater
	 *
	 * @param mixed $text Message you want to logging
	 */
	public function error($text)
	{
		$this->logger->addError($text);
	}

	/**
	 * Critical Log method adpater
	 *
	 * @param mixed $text Message you want to logging
	 */
	public function critical($text)
	{
		$this->logger->addCritical($text);
	}

	/**
	 * Alert Log method adpater
	 *
	 * @param mixed $text Message you want to logging
	 */
	public function alert($text)
	{
		$this->logger->addAlert($text);
	}

	/**
	 * Emergency Log method adpater
	 *
	 * @param mixed $text Message you want to logging
	 */
	public function emergency($text)
	{
		$this->logger->addEmergency($text);
	}

} // END class Log
Back to Top