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


Python logger.Logger类代码示例

本文整理汇总了Python中common.logger.Logger的典型用法代码示例。如果您正苦于以下问题:Python Logger类的具体用法?Python Logger怎么用?Python Logger使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: BatchCrawler

class BatchCrawler():
    
    MAX_DOCS_NUM = 100
    
    def __init__(self, database_config_path, source_name, domain, encode, request_interval):
        self.logger = Logger("crawler", domain)
        self.adapter = DocRawAdapter(database_config_path, source_name, self.logger)
        self.domain = domain
        self.encode = encode 
        self.request_interval = request_interval
    
    def run(self):
        while True:
            count = 0
            try:
                for url_hash, url in self.adapter.load_uncrawled_docs(BatchCrawler.MAX_DOCS_NUM):
                    count += 1
                    self.logger.log("crawling url %s"%url, 2)
                    page = common_utils.page_crawl(url)
                    if page == None:
                        self.adapter.update_doc_raw_as_crawled_failed(url_hash)
                        continue
                    if self.encode != "utf-8":
                        page = unicode(page, self.encode).encode("utf-8")

                    self.adapter.update_doc_raw_with_crawled_page(url_hash, "utf-8", page)
                    time.sleep(float(self.request_interval))
                if count < BatchCrawler.MAX_DOCS_NUM:
                    break
            except:
                self.logger.log("mongo error")
开发者ID:qrodoo-dev,项目名称:backend,代码行数:31,代码来源:batch_crawler.py

示例2: __init__

class DataQueue:
    def __init__(self):
        self.dataQueue = queue.Queue()
        self.dv = datavalidator.DataValidator()
        self.log = Logger().get('database.dataqueue.DataQueue')
    """we want to check the data here and fail early
        if the data is good then we want to put it in the data queue
        we will want another python script for the validations (datavalidator.py)
        we need to enforce type constraints because the database will not
        see datavalidator.py"""
    def insert_into_data_queue(self, value):
        if not self.dv.run_all_checks(value):
            self.log.error('--> Validation failed! Unable to add data '
                           'into data queue: ' +
                           str(value))
            return False
        try:
            self.dataQueue.put(value)
        except queue.Full as e:
            self.log.critical('Data queue is full!')
        finally:
            return True

    def get_next_item(self):
        item = self.dataQueue.get()
        self.dataQueue.task_done()
        return item

    def check_empty(self):
        result = self.dataQueue.empty()
        return result
开发者ID:RECCE7,项目名称:recce7,代码行数:31,代码来源:dataqueue.py

示例3: validate_time_period

def validate_time_period(query_tokens):
    log = Logger().get('reportserver.manager.utilities')
    log.debug("given query_tokens:" + str(query_tokens))

    uom = None
    units = None

    for token in query_tokens:
        if '=' in token:
            uom,units = token.split('=')
            if uom in UnitOfMeasure.get_values(UnitOfMeasure):
                units = int(units)
                break
            else:
                uom  = None
                units = None

    # default if we aren't given valid uom and units
    #TODO:  get this from a config file.
    if uom is None or units is None:
        uom = "days"
        units = 1

    log.debug("validate_time_period: " + str(uom) + ": " + str(units))
    return (uom, units)
开发者ID:RECCE7,项目名称:recce7,代码行数:25,代码来源:utilities.py

示例4: Handler

class Handler(object):

    def __init__(self,section,filename=None,data_results=None):
        self.logger = Logger()
        self.key=ConfigurationManager.readCuckooResultsConfig(variable='key',section=section)
        self.encapsulation = literal_eval(ConfigurationManager.readCuckooResultsConfig(variable='encapsulation',section=section))
        self.keys = list(ConfigurationManager.readCuckooResultsConfig(variable='keys',section=section).split(','))
        #Check if there are not any keys
        if self.keys==['']:
            self.keys=None
        self.subsectionskeys={}
        if self.encapsulation:
            self.subsections = returnsubsections(self.encapsulation,section=section,subsections=[])
            for subsection in self.subsections:
                self.subsectionskeys[ConfigurationManager.readCuckooResultsConfig(variable='key',section='subsection_'+subsection)] = list(ConfigurationManager.readCuckooResultsConfig(variable='keys',section='subsection_'+subsection).split(','))
        results=None
        try:
            if data_results is not None:
                results=data_results[self.key]
            elif filename is not  None:
                results = load_results(filename)[self.key]
        except Exception, e:
            self.logger.errorLogging(str(e))

        if isinstance(results,dict):
            self.dictionary = results
            self.list = None
        elif isinstance(results,list):
            self.list= results
            self.dictionary = None
        else:
            self.list = None
            self.dictionary = None
开发者ID:GeorgeSakUOM,项目名称:thesis_public,代码行数:33,代码来源:cuckoo_results_handler.py

示例5: MatchFiles

def MatchFiles(checkerFile, c1File, targetArch, debuggableMode):
    for testCase in checkerFile.testCases:
        if testCase.testArch not in [None, targetArch]:
            continue
        if testCase.forDebuggable != debuggableMode:
            continue

        # TODO: Currently does not handle multiple occurrences of the same group
        # name, e.g. when a pass is run multiple times. It will always try to
        # match a check group against the first output group of the same name.
        c1Pass = c1File.findPass(testCase.name)
        if c1Pass is None:
            Logger.fail(
                'Test case "{}" not found in the CFG file'.format(testCase.name),
                testCase.fileName,
                testCase.startLineNo,
            )

        Logger.startTest(testCase.name)
        try:
            MatchTestCase(testCase, c1Pass)
            Logger.testPassed()
        except MatchFailedException as e:
            lineNo = c1Pass.startLineNo + e.lineNo
            if e.assertion.variant == TestAssertion.Variant.Not:
                Logger.testFailed(
                    "NOT assertion matched line {}".format(lineNo), e.assertion.fileName, e.assertion.lineNo
                )
            else:
                Logger.testFailed(
                    "Assertion could not be matched starting from line {}".format(lineNo),
                    e.assertion.fileName,
                    e.assertion.lineNo,
                )
开发者ID:RadonX-MM,项目名称:platform_art,代码行数:34,代码来源:file.py

示例6: process_do_maintenance

 def process_do_maintenance(self):
     """ メンテナンスの設定を行う
     """
     if self.operation.maintenance_mode:
         self.operation.render_maintenance_config()
         self.operation.cp_maintenance_config()
         self.operation.nginx.restart()
         Logger.put('メンテナンスを{}にしたよ'.format(self.operation.maintenance_mode))
开发者ID:nabetama,项目名称:nginx-manager,代码行数:8,代码来源:nginx_managerd.py

示例7: render_vhost_conf

 def render_vhost_conf(self):
     template = self.env.get_template('vhost.conf.j2')
     for virtual_host in self.virtual_hosts:
         nginx_config = template.render(virtual_host=virtual_host)
         virtual_host_conf = os.path.join(self.nginx.files_dir, virtual_host.conf)
         with open(virtual_host_conf, 'w+') as dest:
             Logger.put("{}を生成したよー".format(virtual_host_conf))
             dest.write(nginx_config.encode('utf-8'))
开发者ID:nabetama,项目名称:nginx-manager,代码行数:8,代码来源:nginx_managerd.py

示例8: addAssertion

 def addAssertion(self, new_assertion):
   if new_assertion.variant == TestAssertion.Variant.NextLine:
     if not self.assertions or \
        (self.assertions[-1].variant != TestAssertion.Variant.InOrder and \
         self.assertions[-1].variant != TestAssertion.Variant.NextLine):
       Logger.fail("A next-line assertion can only be placed after an "
                   "in-order assertion or another next-line assertion.",
                   new_assertion.fileName, new_assertion.lineNo)
   self.assertions.append(new_assertion)
开发者ID:AOSP-JF,项目名称:platform_art,代码行数:9,代码来源:struct.py

示例9: parse_json

 def parse_json(self):
     init_data = {}
     if not isinstance(self.item['data'], str):
         return False
     try:
         init_data = json.loads(self.item['data'])
     except:
         Logger.put("JSONにできないやつ送られてきた!. {}".format(self.item['data']))
         return False
     self.operation = Operation(init_data)
     return True
开发者ID:nabetama,项目名称:nginx-manager,代码行数:11,代码来源:nginx_managerd.py

示例10: cp

 def cp(self, _from, _to):
     """ cp _from _to
     @param _from str file path
     @param _to str file path
     @return Popen#returncode, res, err
     """
     cp = 'cp -rf {} {}'.format(_from, _to),
     # DEBUG
     Logger.put(cp)
     ret_code, res, err = shell_command(cp)
     return ret_code, res, err
开发者ID:nabetama,项目名称:nginx-manager,代码行数:11,代码来源:nginx_managerd.py

示例11: get_date_delta

def get_date_delta(iso_date_from, iso_date_to):
    try:
        date_from = dateutil.parser.parse(iso_date_from)
        date_to = dateutil.parser.parse(iso_date_to)
        delta = date_to - date_from
    except Exception as e:
        log = Logger().get('reportserver.manager.utilities')
        log.error("Error: " + str(e))
        delta = 0

    return str(delta)
开发者ID:RECCE7,项目名称:recce7,代码行数:11,代码来源:utilities.py

示例12: DumpPass

def DumpPass(outputFilename, passName):
  c1File = ParseC1visualizerStream(os.path.basename(outputFilename), open(outputFilename, "r"))
  compiler_pass = c1File.findPass(passName)
  if compiler_pass:
    maxLineNo = compiler_pass.startLineNo + len(compiler_pass.body)
    lenLineNo = len(str(maxLineNo)) + 2
    curLineNo = compiler_pass.startLineNo
    for line in compiler_pass.body:
      Logger.log((str(curLineNo) + ":").ljust(lenLineNo) + line)
      curLineNo += 1
  else:
    Logger.fail("Pass \"" + passName + "\" not found in the output")
开发者ID:BenzoRoms,项目名称:art,代码行数:12,代码来源:checker.py

示例13: __init__

    def __init__(self, parent, name, body, startLineNo):
        self.parent = parent
        self.name = name
        self.body = body
        self.startLineNo = startLineNo

        if not self.name:
            Logger.fail("C1visualizer pass does not have a name", self.fileName, self.startLineNo)
        if not self.body:
            Logger.fail("C1visualizer pass does not have a body", self.fileName, self.startLineNo)

        self.parent.addPass(self)
开发者ID:RadonX-MM,项目名称:platform_art,代码行数:12,代码来源:struct.py

示例14: update_analyzers_pool

def update_analyzers_pool():
    logger = Logger()
    try:
        global analyzers_pool
        analyzers = open("analyzers", "r")
        fcntl.fcntl(analyzers, fcntl.LOCK_EX)
        data = analyzers.read()
        fcntl.fcntl(analyzers, fcntl.LOCK_UN)
        analyzers.close()
        analyzers_pool = literal_eval(data)
    except Exception, e:
        info = str(e)
        logger.errorLogging(info)
开发者ID:GeorgeSakUOM,项目名称:thesis_public,代码行数:13,代码来源:task_server.py

示例15: __init__

  def __init__(self, parent, name, startLineNo, testArch = None):
    assert isinstance(parent, CheckerFile)

    self.parent = parent
    self.name = name
    self.assertions = []
    self.startLineNo = startLineNo
    self.testArch = testArch

    if not self.name:
      Logger.fail("Test case does not have a name", self.fileName, self.startLineNo)

    self.parent.addTestCase(self)
开发者ID:AOSP-JF,项目名称:platform_art,代码行数:13,代码来源:struct.py


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