Package ZenEvents :: Module syslog_h
[hide private]
[frames] | no frames]

Source Code for Module ZenEvents.syslog_h

 1  ########################################################################### 
 2  # 
 3  # This program is part of Zenoss Core, an open source monitoring platform. 
 4  # Copyright (C) 2007, Zenoss Inc. 
 5  # 
 6  # This program is free software; you can redistribute it and/or modify it 
 7  # under the terms of the GNU General Public License version 2 as published by 
 8  # the Free Software Foundation. 
 9  # 
10  # For complete information please visit: http://www.zenoss.com/oss/ 
11  # 
12  ########################################################################### 
13  # constants from syslog.h 
14  LOG_EMERGENCY   = 0 
15  LOG_ALERT       = 1 
16  LOG_CRITICAL    = 2 
17  LOG_ERRROR      = 3 
18  LOG_WARNING     = 4 
19  LOG_NOTICE      = 5 
20  LOG_INFO        = 6 
21  LOG_DEBUG       = 7 
22   
23  LOG_PRIMASK     = 0x07 
24   
25 -def LOG_PRI(p): return p & LOG_PRIMASK
26 -def LOG_MAKEPRI(fac, pri): return fac << 3 | pri
27 28 LOG_KERN = 0 << 3 29 LOG_USER = 1 << 3 30 LOG_MAIL = 2 << 3 31 LOG_DAEMON = 3 << 3 32 LOG_AUTH = 4 << 3 33 LOG_SYSLOG = 5 << 3 34 LOG_LPR = 6 << 3 35 LOG_NEWS = 7 << 3 36 LOG_UUCP = 8 << 3 37 LOG_CRON = 9 << 3 38 LOG_AUTHPRIV = 10 << 3 39 LOG_FTP = 11 << 3 40 LOG_LOCAL0 = 16 << 3 41 LOG_LOCAL1 = 17 << 3 42 LOG_LOCAL2 = 18 << 3 43 LOG_LOCAL3 = 19 << 3 44 LOG_LOCAL4 = 20 << 3 45 LOG_LOCAL5 = 21 << 3 46 LOG_LOCAL6 = 22 << 3 47 LOG_LOCAL7 = 23 << 3 48 49 LOG_NFACILITIES = 24 50 LOG_FACMASK = 0x03F8
51 -def LOG_FAC(p): return (p & LOG_FACMASK) >> 3
52
53 -def LOG_MASK(pri): return 1 << pri
54 -def LOG_UPTO(pri): return (1 << pri + 1) - 1
55 # end syslog.h 56
57 -def LOG_UNPACK(p): return (p & LOG_FACMASK, LOG_PRI(p))
58 59 fac_values = {} # mapping of facility constants to their values 60 fac_names = {} # mapping of values to names 61 pri_values = {} 62 pri_names = {} 63 for i, j in globals().items(): 64 if i[:4] == 'LOG_' and type(j) == type(0): 65 if j > LOG_PRIMASK or i == 'LOG_KERN': 66 n, v = fac_names, fac_values 67 else: 68 n, v = pri_names, pri_values 69 i = i[4:].lower() 70 v[i] = j 71 n[j] = i 72 del i, j, n, v 73