法师日志(magento)中的null是什么意思? [英] What is the meaning of null in Mage log (magento)?
问题描述
为了创建 Magento 日志,你会写一些类似的东西
Mage::log('Server Side Validation for Year for '.$currentYearType);
但是如果我要将日志添加到单独的文件中,我会吗
Mage::log('Server Side Validation for Year for ' ,null,'serversidevalidation.log');
如果我错了,请纠正我.
如果是,中间的null有什么用?此外,该文件是否需要事先存在,或者我认为它是在需要时由系统创建的.我对吗?另外,它会包括时间戳吗?
转到 app/Mage.php
第 785 行
公共静态函数日志($message, $level = null, $file = '', $forceLog = false)
可以看到第二个参数是level
$level = is_null($level) ?Zend_Log::DEBUG : $level;
libendlog.php
const EMERG = 0;//紧急情况:系统无法使用常量警报 = 1;//警报:必须立即采取行动常量 CRIT = 2;//临界:临界条件const ERR = 3;//错误:错误条件常量警告 = 4;//警告:警告条件常量通知 = 5;//注意:正常但重要的条件常量信息 = 6;//Informational: 信息性消息常量调试 = 7;//调试:调试消息
如果你这个代码 Mage::log('test', 1);
然后你会在日志文件中得到这样的输出
2014-05-17T12:21:51+00:00 ALERT (1): 测试
<块引用>
是的,文件是系统调用时自动创建的
系统在调用时包含时间戳
在第 825 行的 app/Mage.php
中引用这段代码
$format = '%timestamp% %priorityName% (%priority%): %message%' .PHP_EOL;$formatter = new Zend_Log_Formatter_Simple($format);
干杯
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?
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;
libendlog.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
这篇关于法师日志(magento)中的null是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!