关于 Logging Level

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

efi是谁?...为什么都叫他大神。
Muninn
2013 年 12 月 10 日
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 日
整数不标准,不过名字很通用,用法都一样

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

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

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

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

© 2021 V2EX