64 private static $fileLogger;
68 private static $log_name = null;
74 private static $transaction =
false;
80 private static $quenue = array();
86 private static $log_path =
'';
93 self::$log_path =
APP_PATH .
'temp/logs/';
94 if ($name ===
'' || $name ===
true) {
95 $name =
'log' . date(
'Y-m-d') .
'.txt';
97 self::$fileLogger = fopen(self::$log_path . $name,
'a');
98 if (!self::$fileLogger) {
99 throw new KumbiaException(
"No se puede abrir el log llamado: " . $name);
110 self::$log_path = $path;
120 return self::$log_path;
130 public static function log($type=
'DEBUG', $msg, $name_log)
132 self::initialize($name_log);
133 if (!self::$fileLogger) {
134 throw new KumbiaException(
'No se puede enviar mensaje al log porque es invalido');
136 if (is_array($msg)) {
137 $msg = print_r($msg,
true);
139 $date = date(DATE_RFC1036);
140 if (self::$transaction) {
141 self::$quenue[] =
"[$date][$type] " . $msg;
143 fputs(self::$fileLogger,
"[$date][$type] " . $msg . PHP_EOL);
154 self::$transaction =
true;
163 self::$transaction =
false;
164 self::$quenue = array();
172 self::$transaction =
false;
173 foreach (self::$quenue as $msg) {
184 if (!self::$fileLogger) {
185 throw new KumbiaException(
"No se puede cerrar el log porque es invalido");
187 return fclose(self::$fileLogger);
197 public static function warning($msg, $name_log=
'')
199 self::log(
'WARNING', $msg, $name_log);
209 public static function error($msg, $name_log=
'')
211 self::log(
'ERROR', $msg, $name_log);
221 public static function debug($msg, $name_log=
'')
223 self::log(
'DEBUG', $msg, $name_log);
233 public static function alert($msg, $name_log=
'')
235 self::log(
'ALERT', $msg, $name_log);
245 public static function critical($msg, $name_log=
'')
247 self::log(
'CRITICAL', $msg, $name_log);
257 public static function notice($msg, $name_log=
'')
259 self::log(
'NOTICE', $msg, $name_log);
269 public static function info($msg, $name_log=
'')
271 self::log(
'INFO', $msg, $name_log);
283 self::log(
'EMERGENCE', $msg, $name_log);
293 public static function custom($type=
'CUSTOM', $msg, $name_log=
'')
295 self::log($type, $msg, $name_log);