法师日志(magento)中null的含义是什么? [英] What is the meaning of null in Mage log (magento)?

查看:95
本文介绍了法师日志(magento)中null的含义是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为了创建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.

如果是这样,中间的null有什么用? 另外,该文件是否需要事先存在,或者我认为它是由系统在需要时创建的.我对吗?另外,它会包含时间戳吗?

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?

推荐答案

转到app/Mage.php

第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

如果您输入此代码Mage::log('test', 1);

然后您将在日志文件中得到这样的输出

then you get a output in log file like this

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

是的,文件在调用时由系统自动创建

系统在调用时包括时间戳记

在825行的app/Mage.php中引用此代码

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

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

欢呼

这篇关于法师日志(magento)中null的含义是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆