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


Python logging.WARN属性代码示例

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


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

示例1: parse_args

# 需要导入模块: import logging [as 别名]
# 或者: from logging import WARN [as 别名]
def parse_args():
    parser = argparse.ArgumentParser(description = "Bass")
    parser.add_argument("-v", "--verbose", action = "count", default = 0, help = "Increase verbosity")
    parser.add_argument("samples", metavar = "sample", nargs = "+", help = "Sample path") 

    args = parser.parse_args()

    try:
        loglevel = {
            0: logging.ERROR,
            1: logging.WARN,
            2: logging.INFO
        }[args.verbose]
    except KeyError:
        loglevel = logging.DEBUG

    logging.basicConfig(level = loglevel)
    logging.getLogger().setLevel(loglevel)

    return args 
开发者ID:Cisco-Talos,项目名称:BASS,代码行数:22,代码来源:cmdline.py

示例2: parse_args

# 需要导入模块: import logging [as 别名]
# 或者: from logging import WARN [as 别名]
def parse_args():
    parser = argparse.ArgumentParser(description = "Add samples to BASS whitelist")
    parser.add_argument("-v", "--verbose", action = "count", default = 0, help = "Increase verbosity")
    parser.add_argument("--url", type = str, default = "http://localhost:5000", help = "URL of BASS server")
    parser.add_argument("sample", help = "Whitelist sample")

    args = parser.parse_args()

    try:
        loglevel = {
            0: logging.ERROR,
            1: logging.WARN,
            2: logging.INFO}[args.verbose]
    except KeyError:
        loglevel = logging.DEBUG
    logging.basicConfig(level = loglevel)
    logging.getLogger().setLevel(loglevel)

    return args 
开发者ID:Cisco-Talos,项目名称:BASS,代码行数:21,代码来源:whitelist.py

示例3: parse_args

# 需要导入模块: import logging [as 别名]
# 或者: from logging import WARN [as 别名]
def parse_args():
    parser = argparse.ArgumentParser(description = "Find common ngrams in binary files")
    parser.add_argument("-v", "--verbose", action = "count", default = 0, help = "Increase verbosity")
    parser.add_argument("--output", type = str, default = None, help = "Output to file instead of stdout")
    parser.add_argument("--url", type = str, default = "http://localhost:5000", help = "URL of BASS server")
    parser.add_argument("samples", metavar = "sample", nargs = "+", help = "Cluster samples")

    args = parser.parse_args()

    try:
        loglevel = {
            0: logging.ERROR,
            1: logging.WARN,
            2: logging.INFO}[args.verbose]
    except KeyError:
        loglevel = logging.DEBUG
    logging.basicConfig(level = loglevel)
    logging.getLogger().setLevel(loglevel)

    return args 
开发者ID:Cisco-Talos,项目名称:BASS,代码行数:22,代码来源:client.py

示例4: setup_logging

# 需要导入模块: import logging [as 别名]
# 或者: from logging import WARN [as 别名]
def setup_logging(args):
    """Setup the logging level and configure the basic logger
    """
    if args.verbose == 1:
        level = logging.INFO
    elif args.verbose >= 2:
        level = logging.DEBUG
    else:
        level = logging.WARN

    logging.basicConfig(
        format="%(asctime)s - %(levelname)s - %(message)s",
        level=level,
    )

    global LOG
    LOG = logging.getLogger(__name__) 
开发者ID:unode,项目名称:firefox_decrypt,代码行数:19,代码来源:firefox_decrypt.py

示例5: addjobinfo

# 需要导入模块: import logging [as 别名]
# 或者: from logging import WARN [as 别名]
def addjobinfo(self):
        """ The purpose of this method is to populate the job variable
        with the contents from REST (/services/search/jobs/<sid>)

        SPL-112815 - sendalert - not all $job.<param>$ parameters come through

        @raise Exception: raises Exception if search job information could not
                          be retrieved via REST (search/jobs) based on self.sid
        """
        self.job = {}
        if self.sid:
            try:
                response, content = rest.simpleRequest('search/jobs/%s' % self.sid,
                                        sessionKey=self.session_key,
                                        getargs={'output_mode': 'json'})
                if response.status == 200:
                    self.job = json.loads(content)['entry'][0]['content']
                    self.message('Successfully retrieved search job info')
                    self.logger.debug(self.job)
                else:
                    self.message('Could not retrieve search job info', level=logging.WARN)
            except Exception as e:
                self.message('Could not retrieve search job info', level=logging.WARN) 
开发者ID:remg427,项目名称:misp42splunk,代码行数:25,代码来源:cim_actions.py

示例6: setupLoggingWithFile

# 需要导入模块: import logging [as 别名]
# 或者: from logging import WARN [as 别名]
def setupLoggingWithFile(config):
    # set up logging to file - see previous section for more details
    logging.basicConfig(level=logging.DEBUG,
                        format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s',
                        datefmt='%m-%d %H:%M',
                        filename='ffw-debug.log',
                        filemode='w')
    # define a Handler which writes INFO messages or higher to the sys.stderr
    console = logging.StreamHandler()
    console.setLevel(logging.WARN)
    # set a format which is simpler for console use
    formatter = logging.Formatter('%(name)-12s: %(levelname)-8s %(message)s')
    # tell the handler to use this format
    console.setFormatter(formatter)
    # add the handler to the root logger
    logging.getLogger('').addHandler(console)

    # slaves will setup their own logging
    config["DebugWithFile"] = True 
开发者ID:dobin,项目名称:ffw,代码行数:21,代码来源:framework.py

示例7: setupSlaveLoggingWithFile

# 需要导入模块: import logging [as 别名]
# 或者: from logging import WARN [as 别名]
def setupSlaveLoggingWithFile(threadId):
    f = 'ffw-debug-slave-' + str(threadId) + '.log'

    fileh = logging.FileHandler(f, 'a')
    formatter = logging.Formatter('%(asctime)s %(name)-12s %(levelname)-8s %(message)s')
    fileh.setFormatter(formatter)

    log = logging.getLogger()  # root logger
    for hdlr in log.handlers[:]:  # remove all old handlers
        log.removeHandler(hdlr)
    log.addHandler(fileh)      # set the new handler

    # define a Handler which writes INFO messages or higher to the sys.stderr
    console = logging.StreamHandler()
    console.setLevel(logging.WARN)
    # set a format which is simpler for console use
    formatter = logging.Formatter('%(name)-12s: %(levelname)-8s %(message)s')
    # tell the handler to use this format
    console.setFormatter(formatter)
    # add the handler to the root logger
    logging.getLogger('').addHandler(console) 
开发者ID:dobin,项目名称:ffw,代码行数:23,代码来源:utils.py

示例8: run

# 需要导入模块: import logging [as 别名]
# 或者: from logging import WARN [as 别名]
def run(self):
        logging.basicConfig(level=logging.WARN)
        logger = logging.getLogger("ScreepsStats")
        logger.setLevel(logging.INFO)
        formatter = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s")
        handler = logging.FileHandler(base_directory + "/screepsstats.log")
        handler.setFormatter(formatter)
        logger.addHandler(handler)
        websocketprocess = False
        apiprocess = False
        while True:

            if not websocketprocess or not websocketprocess.is_alive():
                websocketprocess = WebsocketProcess()
                websocketprocess.daemon = True
                websocketprocess.start()

            if not apiprocess or not apiprocess.is_alive():
                apiprocess = APIProcess()
                apiprocess.daemon = True
                apiprocess.start()

            time.sleep(3) 
开发者ID:screepers,项目名称:screeps-stats,代码行数:25,代码来源:screepsstats.py

示例9: __call__

# 需要导入模块: import logging [as 别名]
# 或者: from logging import WARN [as 别名]
def __call__(self, *args, **kwargs):
        argmap = {}
        if len(list(args)) != 0:
            for index, value in enumerate(args):
                argmap['param' + str(index+1)] = value
        if len(list(kwargs)) != 0:
            for key in kwargs.keys():
                argmap[key] = kwargs[key]
        try:
            return self.invoker.invoke(self.prefix + '.' + self.name, argmap)
        except CommandInvokerError, e:
            if e.code == 1:
                msg = "'" + self.prefix + "' has no attribute '" + self.name + "' (make sure the command exists and that mcafee.client(...) was called prior to invoking the command)"
                log(logging.WARN, msg)
                raise AttributeError(msg)
            else:
                log(logging.ERROR, e.msg)
                raise e 
开发者ID:rapid7,项目名称:insightconnect-plugins,代码行数:20,代码来源:mcafee.py

示例10: __getattr__

# 需要导入模块: import logging [as 别名]
# 或者: from logging import WARN [as 别名]
def __getattr__(self, attr):
        """
        When the caller requests attributes that are not available, assume
        the caller wants to create a _PyCommand.  Also catch calls that dir()
        makes so we can return a list of commands
        """
        cmd = attr # for clarity...this is the command name, ie, listUsers

        #We must catch accessing __members__,__repr__, and __str__ attributes
        #otherwise it will attempt to create a PyCommand and hence hit the server
        #which we don't want.
        if cmd == '__members__':
            return # there are no members of a PyClient, only methods
        if cmd == '__methods__':
            return _get_command_names(self._invoker, self._module)
        if cmd == '__repr__':
            return # should anything be returned here?
        if cmd == '__str__':
            return # should anything be returned here?
        if cmd == '__call__':
            msg = "'" + self._module + "' object is not callable"
            log(logging.WARN, msg)
            raise TypeError(msg)
        pc = _PyCommand(self._invoker, self._module, cmd)
        return pc 
开发者ID:rapid7,项目名称:insightconnect-plugins,代码行数:27,代码来源:mcafee.py

示例11: create_console_handler

# 需要导入模块: import logging [as 别名]
# 或者: from logging import WARN [as 别名]
def create_console_handler(verbose_level):
    clog = logging.StreamHandler()
    formatter = ColoredFormatter(
        "%(log_color)s[%(asctime)s %(levelname)-8s%(module)s]%(reset)s "
        "%(white)s%(message)s",
        datefmt="%H:%M:%S",
        reset=True,
        log_colors={
            'DEBUG': 'cyan',
            'INFO': 'green',
            'WARNING': 'yellow',
            'ERROR': 'red',
            'CRITICAL': 'red',
        })

    clog.setFormatter(formatter)

    if verbose_level == 0:
        clog.setLevel(logging.WARN)
    elif verbose_level == 1:
        clog.setLevel(logging.INFO)
    else:
        clog.setLevel(logging.DEBUG)

    return clog 
开发者ID:hyperledger,项目名称:sawtooth-core,代码行数:27,代码来源:main.py

示例12: parse_args

# 需要导入模块: import logging [as 别名]
# 或者: from logging import WARN [as 别名]
def parse_args(args: Sequence) -> argparse.Namespace:
    """Parse command-line arguments."""
    parser = argparse.ArgumentParser(
        description=(
            "A blazing fast LookML parser, implemented in pure Python. "
            "When invoked from the command line, "
            "returns the parsed output as a JSON string."
        )
    )
    parser.add_argument(
        "file", type=argparse.FileType("r"), help="path to the LookML file to parse"
    )
    parser.add_argument(
        "-d",
        "--debug",
        action="store_const",
        dest="log_level",
        const=logging.DEBUG,
        default=logging.WARN,
        help="increase logging verbosity",
    )

    return parser.parse_args(args) 
开发者ID:joshtemple,项目名称:lkml,代码行数:25,代码来源:__init__.py

示例13: cli

# 需要导入模块: import logging [as 别名]
# 或者: from logging import WARN [as 别名]
def cli():
    """Command-line entry point for lkml."""
    logger = logging.getLogger()
    logger.setLevel(logging.WARN)

    handler = logging.StreamHandler()
    handler.setLevel(logging.DEBUG)

    formatter = logging.Formatter("%(name)s %(levelname)s: %(message)s")

    handler.setFormatter(formatter)
    logger.addHandler(handler)

    args = parse_args(sys.argv[1:])

    logging.getLogger().setLevel(args.log_level)

    lookml = load(args.file)
    args.file.close()

    json_string = json.dumps(lookml, indent=2)
    print(json_string) 
开发者ID:joshtemple,项目名称:lkml,代码行数:24,代码来源:__init__.py

示例14: set_log

# 需要导入模块: import logging [as 别名]
# 或者: from logging import WARN [as 别名]
def set_log(level, filename='spider.log'):
    """
    return a log file object
    根据提示设置log打印
    """
    if not os.path.isdir(LOG_DIR):
    	os.mkdir(LOG_DIR)
    log_file = os.path.join(LOG_DIR, filename)
    if not os.path.isfile(log_file):
        os.mknod(log_file)
        os.chmod(log_file, 0777)
    log_level_total = {'debug': logging.DEBUG, 'info': logging.INFO, 'warning': logging.WARN, 'error': logging.ERROR,
                       'critical': logging.CRITICAL}
    logger_f = logging.getLogger('spider')
    logger_f.setLevel(logging.DEBUG)
    fh = logging.FileHandler(log_file,'a')
    fh.setLevel(log_level_total.get(level, logging.DEBUG))
    formatter = logging.Formatter('%(asctime)s  %(filename)s  [line:%(lineno)d] %(levelname)s  %(message)s')
    fh.setFormatter(formatter)
    logger_f.addHandler(fh)
    keep_fds = [fh.stream.fileno()]
    return logger_f,keep_fds 
开发者ID:shancang,项目名称:spider,代码行数:24,代码来源:common.py

示例15: setup_custom_logger

# 需要导入模块: import logging [as 别名]
# 或者: from logging import WARN [as 别名]
def setup_custom_logger(name):
    formatter = logging.Formatter(
        STY_DESC_DEBUG + '%(asctime)s - %(module)s - %(levelname)8s - %(message)s' +
            style.RESET, datefmt='%Y-%b-%d %H:%M:%S')

    handler = logging.StreamHandler()
    handler.setFormatter(formatter)

    logger = logging.getLogger(name)
    logger.setLevel(logging.WARN)
    logger.addHandler(handler)
    return logger

    # self.logger = logging.getLogger(self.BOTNAME)
    # self.logger.setLevel(logging.DEBUG)

    # self.ch.setLevel(logging.WARN)
    # # ch.setLevel(logging.DEBUG)
    # self.ch.setFormatter(self.formatter)
    # self.logger.addHandler(self.ch) 
开发者ID:nmstoker,项目名称:lockebot,代码行数:22,代码来源:util.py


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