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

# Source Code for Module Products.ZenEvents.syslog_h

     1  ##############################################################################
     2  #
     3  # Copyright (C) Zenoss, Inc. 2007, all rights reserved.
     4  #
     5  # This content is made available according to terms specified in
     6  # License.zenoss under the directory where your Zenoss product is installed.
     7  #
     8  ##############################################################################
     9
    10
    11  # constants from syslog.h
    12  LOG_EMERGENCY   = 0
    13  LOG_ALERT       = 1
    14  LOG_CRITICAL    = 2
    15  LOG_ERRROR      = 3
    16  LOG_WARNING     = 4
    17  LOG_NOTICE      = 5
    18  LOG_INFO        = 6
    19  LOG_DEBUG       = 7
    20
    21  LOG_PRIMASK     = 0x07
    22
    23 -def LOG_PRI(p): return p & LOG_PRIMASK
    24 -def LOG_MAKEPRI(fac, pri): return fac << 3 | pri
    25
    26  LOG_KERN        = 0 << 3
    27  LOG_USER        = 1 << 3
    28  LOG_MAIL        = 2 << 3
    29  LOG_DAEMON      = 3 << 3
    30  LOG_AUTH        = 4 << 3
    31  LOG_SYSLOG      = 5 << 3
    32  LOG_LPR         = 6 << 3
    33  LOG_NEWS        = 7 << 3
    34  LOG_UUCP        = 8 << 3
    35  LOG_CRON        = 9 << 3
    36  LOG_AUTHPRIV    = 10 << 3
    37  LOG_FTP         = 11 << 3
    38  LOG_LOCAL0      = 16 << 3
    39  LOG_LOCAL1      = 17 << 3
    40  LOG_LOCAL2      = 18 << 3
    41  LOG_LOCAL3      = 19 << 3
    42  LOG_LOCAL4      = 20 << 3
    43  LOG_LOCAL5      = 21 << 3
    44  LOG_LOCAL6      = 22 << 3
    45  LOG_LOCAL7      = 23 << 3
    46
    47  LOG_NFACILITIES = 24
    48  LOG_FACMASK     = 0x03F8
    49 -def LOG_FAC(p): return (p & LOG_FACMASK) >> 3
    50
    51 -def LOG_MASK(pri): return 1 << pri
    52 -def LOG_UPTO(pri): return (1 << pri + 1) - 1
    53  # end syslog.h
    54
    55 -def LOG_UNPACK(p): return (LOG_FAC(p), LOG_PRI(p))
    56
    57  fac_values = {}     # mapping of facility constants to their values
    58  fac_names = {}      # mapping of values to names
    59  pri_values = {}
    60  pri_names = {}
    61  for i, j in globals().items():
    62      if i[:4] == 'LOG_' and isinstance(j, int):
    63          if j > LOG_PRIMASK or i == 'LOG_KERN':
    64              n, v = fac_names, fac_values
    65          else:
    66              n, v = pri_names, pri_values
    67          i = i[4:].lower()
    68          v[i] = j
    69          n[j] = i
    70  del i, j, n, v
    71