V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
Livid
V2EX  ›  Python

关于 Logging Level

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

    efi是谁?...为什么都叫他大神。
    Muninn
        10
    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
        11
    hhkbp2  
       2013-12-10 11:41:43 +08:00
    整数不标准,不过名字很通用,用法都一样
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   871 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 22:50 · PVG 06:50 · LAX 15:50 · JFK 18:50
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.