Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the meaning of null in Mage log (magento)?

In order to create Magento log, one would write something like

 Mage::log('Server Side Validation kicked in for Year for '.$currentYearType);

But if I were to add the log in a sepearate file , do I

Mage::log('Server Side Validation kicked in for Year for ' ,null,'serversidevalidation.log');

Please correct me if I am wrong.

If so, what is the use of null in the middle? Also, does the file need to exist before hand or I think it is created by system when needed. Am I right? Also, will it include timestamp?

like image 758
Hello Universe Avatar asked May 17 '14 11:05

Hello Universe


1 Answers

Go to to app/Mage.php

line 785

public static function log($message, $level = null, $file = '', $forceLog = false) 

you can see the second paramete is level

$level  = is_null($level) ? Zend_Log::DEBUG : $level;

lib\Zend\log.php

const EMERG   = 0;  // Emergency: system is unusable
const ALERT   = 1;  // Alert: action must be taken immediately
const CRIT    = 2;  // Critical: critical conditions
const ERR     = 3;  // Error: error conditions
const WARN    = 4;  // Warning: warning conditions
const NOTICE  = 5;  // Notice: normal but significant condition
const INFO    = 6;  // Informational: informational messages
const DEBUG   = 7;  // Debug: debug messages

if you this code Mage::log('test', 1);

then you get a output in log file like this

2014-05-17T12:21:51+00:00 ALERT (1): test

Yes, the file is automatically created by system when its call

system include the timestamp when it call

refer this code in app/Mage.php in line 825

 $format = '%timestamp% %priorityName% (%priority%): %message%' . PHP_EOL;
 $formatter = new Zend_Log_Formatter_Simple($format);

Cheers

like image 179
MeenakshiSundaram R Avatar answered Nov 04 '22 01:11

MeenakshiSundaram R