當前位置: 首頁>>代碼示例>>Python>>正文


Python syslog.LOG_WARNING屬性代碼示例

本文整理匯總了Python中syslog.LOG_WARNING屬性的典型用法代碼示例。如果您正苦於以下問題:Python syslog.LOG_WARNING屬性的具體用法?Python syslog.LOG_WARNING怎麽用?Python syslog.LOG_WARNING使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在syslog的用法示例。


在下文中一共展示了syslog.LOG_WARNING屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: send

# 需要導入模塊: import syslog [as 別名]
# 或者: from syslog import LOG_WARNING [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: error_log

# 需要導入模塊: import syslog [as 別名]
# 或者: from syslog import LOG_WARNING [as 別名]
def error_log(msg):
    syslogout(msg, logLevel=syslog.LOG_ERR)

#################################
# Function name:
#   warn_log
#
# Function overview:
#   Output to the syslog(LOG_WARNING level)
#
# Argument:
#   msg : Message string
#
# Return value:
#   None
#
################################# 
開發者ID:ntt-sic,項目名稱:masakari,代碼行數:19,代碼來源:libvirt_eventfilter.py

示例3: warn_log

# 需要導入模塊: import syslog [as 別名]
# 或者: from syslog import LOG_WARNING [as 別名]
def warn_log(msg):
    syslogout(msg, logLevel=syslog.LOG_WARNING)

#################################
# Function name:
#   syslogout
#
# Function overview:
#   Output to the syslog
#
# Argument:
#   msg      : Message string
#   logLevel : Output level to syslog
#              Default is LOG_DEBUG
#
# Return value:
#   None
#
################################# 
開發者ID:ntt-sic,項目名稱:masakari,代碼行數:21,代碼來源:libvirt_eventfilter.py

示例4: _retry_on_deadlock

# 需要導入模塊: import syslog [as 別名]
# 或者: from syslog import LOG_WARNING [as 別名]
def _retry_on_deadlock(fn):
    """Decorator to retry a DB API call if Deadlock was received."""
    lock_messages_error = ['Deadlock found', 'Lock wait timeout exceeded']

    @wraps(fn)
    def wrapped(*args, **kwargs):
        while True:
            try:
                return fn(*args, **kwargs)
            except dbexc.OperationalError as e:
                if any(msg in e.message for msg in lock_messages_error):
                    # msg = ("Deadlock detected when running %s Retrying..." %
                    #        (fn.__name__))
                    # rc_util.syslogout(msg, syslog.LOG_WARNING)
                    # Retry!
                    time.sleep(0.5)
                    continue
    return wrapped 
開發者ID:ntt-sic,項目名稱:masakari,代碼行數:20,代碼來源:api.py

示例5: log

# 需要導入模塊: import syslog [as 別名]
# 或者: from syslog import LOG_WARNING [as 別名]
def log(program, function, msg, level="I", display=True):
    global LAST_SHOWN
    # open syslog
    syslog.openlog("system: %s %s:%s:" % (level, program, function))
    # set priority
    priority = syslog.LOG_INFO
    if level == "E":
        priority = syslog.LOG_ERR
    elif level == "W":
        priority = syslog.LOG_WARNING
    priority |= syslog.LOG_LOCAL4
    # write to syslog
    syslog.syslog(priority, msg)
    #
    # NOTE: showlog / showlog -f to check the logs
    #

    if display:
        program_display = " %s: " % program
        displayed = " "
        # If loglevel is anything else than I, add it to our tag
        if level != "I":
            displayed += "[%s] " % level
        displayed += utf8_str(msg)
        # print using FBInk (via cFFI)
        fbink.fbink_print(fbink.FBFD_AUTO, "%s\n%s" % (program_display, displayed), FBINK_CFG) 
開發者ID:barsanuphe,項目名稱:librariansync,代碼行數:28,代碼來源:kindle_logging.py

示例6: warning

# 需要導入模塊: import syslog [as 別名]
# 或者: from syslog import LOG_WARNING [as 別名]
def warning(msg):
    syslog.syslog(syslog.LOG_WARNING, _encode(msg)) 
開發者ID:kdart,項目名稱:pycopia,代碼行數:4,代碼來源:logging.py

示例7: loglevel_warning

# 需要導入模塊: import syslog [as 別名]
# 或者: from syslog import LOG_WARNING [as 別名]
def loglevel_warning():
    loglevel(syslog.LOG_WARNING) 
開發者ID:kdart,項目名稱:pycopia,代碼行數:4,代碼來源:logging.py

示例8: test_format_colored_with_level_warning

# 需要導入模塊: import syslog [as 別名]
# 或者: from syslog import LOG_WARNING [as 別名]
def test_format_colored_with_level_warning(self):
        self.message.level = syslog.LOG_WARNING
        log = TailFormatter('({source}) - {message}', color=True).format(self.message)
        self.assertEquals(colored('(dummy.source) - dummy message', 'yellow'), log) 
開發者ID:globocom,項目名稱:glog-cli,代碼行數:6,代碼來源:test_formats.py

示例9: test_get_log_level_from_code

# 需要導入模塊: import syslog [as 別名]
# 或者: from syslog import LOG_WARNING [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

示例10: test_get_log_level_code

# 需要導入模塊: import syslog [as 別名]
# 或者: from syslog import LOG_WARNING [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

示例11: Open_valve

# 需要導入模塊: import syslog [as 別名]
# 或者: from syslog import LOG_WARNING [as 別名]
def Open_valve():
    if Refilling() == True:
        Alert("RO/DI Valve already opened",syslog.LOG_WARNING)
        sys.exit(5)
    else:
        Alert("Opening the RO/DI valve",syslog.LOG_NOTICE)
        try:
            urllib2.urlopen("http://192.168.0.150/set.cmd?user=admin+pass=12345678+cmd=setpower+p61=1", timeout = 10)
            time.sleep(5)
        except urllib2.URLError as e:
            Send_alert("Cannot communicate with valve: " + type(e), syslog.LOG_ERR)
        time.sleep(VALVE_CHGSTATE_TIMER) 
開發者ID:aquamonitor,項目名稱:Aquamonitor,代碼行數:14,代碼來源:rodi-1.8.py

示例12: Repeat_alert

# 需要導入模塊: import syslog [as 別名]
# 或者: from syslog import LOG_WARNING [as 別名]
def Repeat_alert(probe, message, timer):
    global Alarms
    if datetime.now() > Alarms[probe] + timedelta(minutes=timer):
        Send_alert(message,syslog.LOG_WARNING)
        Alarms[probe] = datetime.now()                                        # reset alarm timestamp to reset the counter for next iteration 
開發者ID:aquamonitor,項目名稱:Aquamonitor,代碼行數:7,代碼來源:aquamonitor-1.8.py

示例13: action

# 需要導入模塊: import syslog [as 別名]
# 或者: from syslog import LOG_WARNING [as 別名]
def action(**kwargs):
    try:
        return __action(**kwargs)
    except Exception, e:
        redata = kwargs['redata']
        syslog.syslog(
            syslog.LOG_WARNING,
            'http: Reaction {id} failed: {message}'.format(
                id=redata['id'], message=e.message))
        return False 
開發者ID:Runbook,項目名稱:runbook,代碼行數:12,代碼來源:__init__.py

示例14: syslogout

# 需要導入模塊: import syslog [as 別名]
# 或者: from syslog import LOG_WARNING [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

示例15: tail_format

# 需要導入模塊: import syslog [as 別名]
# 或者: from syslog import LOG_WARNING [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_WARNING屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。