当前位置: 首页>>代码示例>>Python>>正文


Python syslog.LOG_CRIT属性代码示例

本文整理汇总了Python中syslog.LOG_CRIT属性的典型用法代码示例。如果您正苦于以下问题:Python syslog.LOG_CRIT属性的具体用法?Python syslog.LOG_CRIT怎么用?Python syslog.LOG_CRIT使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在syslog的用法示例。


在下文中一共展示了syslog.LOG_CRIT属性的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: send

# 需要导入模块: import syslog [as 别名]
# 或者: from syslog import LOG_CRIT [as 别名]
def send(self, body, title='', notify_type=NotifyType.INFO, **kwargs):
        """
        Perform Syslog Notification
        """

        _pmap = {
            NotifyType.INFO: syslog.LOG_INFO,
            NotifyType.SUCCESS: syslog.LOG_NOTICE,
            NotifyType.FAILURE: syslog.LOG_CRIT,
            NotifyType.WARNING: syslog.LOG_WARNING,
        }

        # Always call throttle before any remote server i/o is made
        self.throttle()
        try:
            syslog.syslog(_pmap[notify_type], body)

        except KeyError:
            # An invalid notification type was specified
            self.logger.warning(
                'An invalid notification type '
                '({}) was specified.'.format(notify_type))
            return False

        return True 
开发者ID:caronc,项目名称:apprise,代码行数:27,代码来源:NotifySyslog.py

示例2: critical

# 需要导入模块: import syslog [as 别名]
# 或者: from syslog import LOG_CRIT [as 别名]
def critical(msg):
    syslog.syslog(syslog.LOG_CRIT, _encode(msg)) 
开发者ID:kdart,项目名称:pycopia,代码行数:4,代码来源:logging.py

示例3: loglevel_critical

# 需要导入模块: import syslog [as 别名]
# 或者: from syslog import LOG_CRIT [as 别名]
def loglevel_critical():
    loglevel(syslog.LOG_CRIT) 
开发者ID:kdart,项目名称:pycopia,代码行数:4,代码来源:logging.py

示例4: test_format_colored_with_level_critical

# 需要导入模块: import syslog [as 别名]
# 或者: from syslog import LOG_CRIT [as 别名]
def test_format_colored_with_level_critical(self):
        self.message.level = syslog.LOG_CRIT
        log = TailFormatter('({source}) - {message}', color=True).format(self.message)
        self.assertEquals(colored('(dummy.source) - dummy message', 'white', 'on_red'), log) 
开发者ID:globocom,项目名称:glog-cli,代码行数:6,代码来源:test_formats.py

示例5: test_get_log_level_from_code

# 需要导入模块: import syslog [as 别名]
# 或者: from syslog import LOG_CRIT [as 别名]
def test_get_log_level_from_code(self):
        self.assertEquals('CRITICAL', LogLevel.find_by_syslog_code(syslog.LOG_CRIT)['name'])
        self.assertEquals('WARNING', LogLevel.find_by_syslog_code(syslog.LOG_WARNING)['name'])
        self.assertEquals('DEBUG', LogLevel.find_by_syslog_code(syslog.LOG_DEBUG)['name'])
        self.assertEquals('INFO', LogLevel.find_by_syslog_code(syslog.LOG_INFO)['name'])
        self.assertEquals('ERROR', LogLevel.find_by_syslog_code(syslog.LOG_ERR)['name'])
        self.assertEquals('NOTICE', LogLevel.find_by_syslog_code(syslog.LOG_NOTICE)['name'])
        self.assertEquals('', LogLevel.find_by_syslog_code(9999)['name']) 
开发者ID:globocom,项目名称:glog-cli,代码行数:10,代码来源:test_formats.py

示例6: test_get_log_level_code

# 需要导入模块: import syslog [as 别名]
# 或者: from syslog import LOG_CRIT [as 别名]
def test_get_log_level_code(self):
        self.assertEquals(syslog.LOG_CRIT, LogLevel.find_by_level_name('CRITICAL'))
        self.assertEquals(syslog.LOG_WARNING, LogLevel.find_by_level_name('WARNING'))
        self.assertEquals(syslog.LOG_DEBUG, LogLevel.find_by_level_name('DEBUG'))
        self.assertEquals(syslog.LOG_INFO, LogLevel.find_by_level_name('INFO'))
        self.assertEquals(syslog.LOG_ERR, LogLevel.find_by_level_name('ERROR'))
        self.assertEquals(syslog.LOG_NOTICE, LogLevel.find_by_level_name('NOTICE'))
        self.assertIsNone(LogLevel.find_by_level_name('UNKNOWN')) 
开发者ID:globocom,项目名称:glog-cli,代码行数:10,代码来源:test_formats.py

示例7: syslogout

# 需要导入模块: import syslog [as 别名]
# 或者: from syslog import LOG_CRIT [as 别名]
def syslogout(msg, logLevel=syslog.LOG_DEBUG, logFacility=syslog.LOG_USER):

    # Output to the syslog.
    arg0 = os.path.basename(sys.argv[0])
    host = socket.gethostname()

    logger = logging.getLogger()
    logger.setLevel(logging.DEBUG)

    f = "%(asctime)s " + host + \
        " %(module)s(%(process)d): %(levelname)s: %(message)s"

    formatter = logging.Formatter(fmt=f, datefmt='%b %d %H:%M:%S')

    fh = logging.FileHandler(
        filename='/var/log/masakari/masakari-instancemonitor.log')
    fh.setLevel(logging.DEBUG)
    fh.setFormatter(formatter)

    logger.addHandler(fh)

    if logLevel == syslog.LOG_DEBUG:
        logger.debug(msg)
    elif logLevel == syslog.LOG_INFO or logLevel == syslog.LOG_NOTICE:
        logger.info(msg)
    elif logLevel == syslog.LOG_WARNING:
        logger.warn(msg)
    elif logLevel == syslog.LOG_ERR:
        logger.error(msg)
    elif logLevel == syslog.LOG_CRIT or \
            logLevel == syslog.LOG_ALERT or \
            logLevel == syslog.LOG_EMERGE:
        logger.critical(msg)
    else:
        logger.debug(msg)

    logger.removeHandler(fh)

#################################
# Function name:
#   virEventFilter
#
# Function overview:
#   Filter events from libvirt.
#
# Argument:
#   eventID   : EventID
#   eventType : Event type
#   detail    : Event name
#   uuID      : UUID
#
# Return value:
#   None
#
################################# 
开发者ID:ntt-sic,项目名称:masakari,代码行数:57,代码来源:libvirt_eventfilter.py

示例8: tail_format

# 需要导入模块: import syslog [as 别名]
# 或者: from syslog import LOG_CRIT [as 别名]
def tail_format(fields=["source", "facility", "line", "module"], color=True):
    def format(entry):
        message_text = entry.message
        timestamp = entry.timestamp.to('local')
        level_string = entry.level

        log_color = 'green'
        log_background = None

        if entry.level == syslog.LOG_CRIT:
            log_color = 'white'
            log_background = 'on_red'
            level_string = "CRITICAL"
        elif entry.level == syslog.LOG_ERR:
            log_color = 'red'
            level_string = "ERROR   "
        elif entry.level == syslog.LOG_WARNING:
            log_color = 'yellow'
            level_string = "WARNING "
        elif entry.level == syslog.LOG_NOTICE:
            log_color = 'green'
            level_string = "NOTICE  "
        elif entry.level == syslog.LOG_INFO:
            log_color = 'green'
            level_string = "INFO    "
        elif entry.level == syslog.LOG_DEBUG:
            log_color = 'blue'
            level_string = "DEBUG   "

        if message_text:
            message_text = " " + message_text + " #"

        local_fields = list(fields)
        if "message" in local_fields:
            local_fields.remove("message")

        field_text = map(lambda f: "{}:{}".format(f, entry.message_dict.get(f, "")), local_fields)

        log = "{level_string}[{timestamp}]{message_text} {field_text}".format(
            timestamp=timestamp.format("YYYY-MM-DD HH:mm:ss.SS"),
            level_string=level_string,
            message_text=message_text,
            field_text="; ".join(field_text))
        if color:
            return colored(log, log_color, log_background)
        else:
            return log

    return format 
开发者ID:blue-yonder,项目名称:bonfire,代码行数:51,代码来源:formats.py


注:本文中的syslog.LOG_CRIT属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。