关于 Logging Level

2013-12-10 03:55:00 +08:00
 Livid
如果需要用整数来表示 FATAL / ERROR / DEBUG 等等 level 的话,目前在业界有没有一套标准之类的?
3920 次点击
所在节点    Python
11 条回复
ivenvd
2013-12-10 04:15:15 +08:00
为啥要用整数表示呢,可以直接用 logging.debug() 之类的函数吧……
非要用的话可以用 logging.DEBUG ……
zhangxiao
2013-12-10 05:27:27 +08:00
zhangxiao
2013-12-10 05:30:38 +08:00
不知道有没有整型的标准,不过不妨把kern_levels.h里定义的字符串当成hex值来看
efi
2013-12-10 06:56:59 +08:00
Livid
2013-12-10 07:23:57 +08:00
@efi 谢谢大神。
GTim
2013-12-10 09:03:26 +08:00
另外 php的error也不错
thbourlove
2013-12-10 10:52:03 +08:00
ms2008
2013-12-10 11:04:35 +08:00
@thbourlove
这个前面是基于RFC2119,是规定 RFC 本身的用语,并不符合楼主的需求。而后面虽然也有LogLevel,但都是一些字符常数,目测也是根据RFC5424或RFC3164而来...
liuxurong
2013-12-10 11:12:20 +08:00
@efi
@Livid
@webjin
@ms2008

efi是谁?...为什么都叫他大神。
Muninn
2013-12-10 11:32:51 +08:00
679 # from <linux/sys/syslog.h>:
680 # ======================================================================
681 # priorities/facilities are encoded into a single 32-bit quantity, where
682 # the bottom 3 bits are the priority (0-7) and the top 28 bits are the
683 # facility (0-big number). Both the priorities and the facilities map
684 # roughly one-to-one to strings in the syslogd(8) source code. This
685 # mapping is included in this file.
686 #
687 # priorities (these are ordered)
688
689 LOG_EMERG = 0 # system is unusable
690 LOG_ALERT = 1 # action must be taken immediately
691 LOG_CRIT = 2 # critical conditions
692 LOG_ERR = 3 # error conditions
693 LOG_WARNING = 4 # warning conditions
694 LOG_NOTICE = 5 # normal but significant condition
695 LOG_INFO = 6 # informational
696 LOG_DEBUG = 7 # debug-level messages


python的源码里也是一致的.
hhkbp2
2013-12-10 11:41:43 +08:00
整数不标准,不过名字很通用,用法都一样

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/92493

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX