• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python logger.Logger类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: _validate_building_data

   def _validate_building_data(self, b_dict):
      """
      Ensure a dictionary containing building information is actually valid
      for updating purposes. The main goal is to validate the presence and
      format of b_id and/or l_b_id.

      If no b_id is present but a l_b_id is valid, it is set as current b_id,
      which ensures the building does not get discarded.

      Arguments:
      - b_dict: a dictionary representing a building

      Return value: True if data is valid, False otherwise
      """
      b_id     = b_dict.get("b_id", "")
      l_b_id   = b_dict.get("l_b_id", "")

      if not Building.is_valid_bid(b_id):
         if Building.is_valid_bid(l_b_id):
            Logger.warning(
               "Invalid building id: \"{}\"".format(b_id),
               "- legacy id", l_b_id, "will be used instead."
               )
            b_dict["b_id"] = l_b_id
         else:
            Logger.error(
               "Building discarded:",
               "Invalid building id", b_id,
               "and no valid legacy id is present"
               )
            return False

      return True
开发者ID:khamusa,项目名称:spazi-unimi,代码行数:33,代码来源:building_data_updater.py


示例2: find_matches

 def find_matches(subscriptions, reddit, database):
     Logger.log('Finding Matches...', Color.GREEN)
     subreddits = {}
     matches = []
     for subscription in subscriptions:
         subreds = subscription.data[Subscription.SUBREDDITS]
         for subreddit in subreds:
             if subreddit.lower() not in [k.lower() for k in subreddits.keys()]:
                 Logger.log(subreddit.lower(), Color.CYAN)
                 submissions = reddit.get_submissions(subreddit.lower())
                 temp = []
                 for sub in submissions:
                     temp.append(sub)
                 subreddits[subreddit.lower()] = temp
             submissions = subreddits[subreddit.lower()]
             # submissions = reddit.get_submissions(subreddit)
             num = 0
             for submission in submissions:
                 num += 1
                 is_match, mismatched_keys = MatchFinder.is_match(subscription, submission)
                 if is_match:
                     already_exists = database.check_if_match_exists(subscription.username,
                                                                     subscription.to_string(),
                                                                     submission.permalink)
                     if not already_exists:
                         matches.append((subscription, submission))
     return matches
开发者ID:tylerbrockett,项目名称:reddit-bot-buildapcsales,代码行数:27,代码来源:match_finder.py


示例3: __init__

 def __init__(self, quiet_start=0, quiet_end=0):
     if quiet_end < quiet_start:
         Logger.log('Invalid Quiet Hours.', Color.RED)
         exit()
     self.quiet_start = quiet_start
     self.quiet_stop = quiet_end
     self.is_quiet = False
开发者ID:tylerbrockett,项目名称:reddit-bot-buildapcsales,代码行数:7,代码来源:times.py


示例4: __init__

class Configuration:
    
    def __init__(self, config_file = 'planner.ini'):
        self.logger = Logger().getLogger("configuration.Configuration")
        self._config_file = config_file
        current_directory = os.path.dirname(os.path.abspath(__file__))
        self._config_file_path = os.path.join(current_directory, '../etc/' + config_file)
        self.logger.debug('Initialize Configuration with ' + self._config_file_path)
        
        self.config = ConfigParser.ConfigParser()
        self.config.read(self._config_file_path)
    
    def get(self, section,option):
        if self.config.has_section(section) and self.config.has_option(section,option) :
            return self.config.get(section, option)
        else:
            return None
    
    def getDict(self, section,option):
        '''dict example: {1:'aaa',2:'bbb'}'''
        value = self.get(section, option)
        if value is not None:
            return ast.literal_eval(value)
        else:
            return value
开发者ID:vollov,项目名称:py-lab,代码行数:25,代码来源:__init__.py


示例5: get_name

class UBSan:
    def get_name(self):
        return self.name


    def __init__(self, benchmark_path, log_file_path):
        self.pipeline = MakePipeline(benchmark_path)
        self.name = "UBSan"
        self.logger = Logger(log_file_path, self.name)
        self.output_dict = {}
        self.tp_set = set([])
        self.fp_set = set([])
        self.neg_count = 0
        os.chdir(os.path.expanduser(benchmark_path))

    def run(self):
        self.pipeline.build_benchmark(CC="clang", CFLAGS="-g -fsanitize=undefined -fsanitize=integer", LD="clang")
        self.pipeline.run_bechmark(self, [], 2)
        return self.output_dict

    def get_output_dict(self):
        return self.output_dict

    def get_tp_set(self):
        print len(self.tp_set)
        return self.tp_set

    def get_fp_set(self):
        print len(self.fp_set)
        return self.fp_set

    def analyze_output(self, exit_code, stdout, stderr, cur_dir, i, j):
        if len(stderr) > 0:
            print(stderr)
        if i not in self.output_dict:
            self.output_dict[i] = {"count": 0, "TP": 0, "FP": 0}
        self.output_dict[i]["count"] += 1
        if "runtime error" in (stdout + stderr).lower():
            if "w_Defects" in cur_dir:
                self.output_dict[i]["TP"] += 1
                self.logger.log_output(stderr, i, cur_dir, j, "TP")
                self.tp_set.add((i, j))
            else:
                self.output_dict[i]["FP"] += 1
                self.logger.log_output(stderr, i, cur_dir, j, "FP")
                self.fp_set.add((i, j))
        else:
            self.logger.log_output(stdout, i, cur_dir, j, "NEG")
            self.neg_count += 1

    def analyze_timeout(self, cur_dir, i, j):
        if i not in self.output_dict:
            self.output_dict[i] = {"count": 0, "TP": 0, "FP": 0}
        self.output_dict[i]["count"] += 1
        self.logger.log_output("", i, cur_dir, j, "NEG")
        self.neg_count += 1

    def cleanup(self):
        self.pipeline.clean_benchmark()
        self.logger.close_log()
开发者ID:osamagid,项目名称:evaluation,代码行数:60,代码来源:ub_san.py


示例6: prepare_rooms

   def prepare_rooms(self, floor_id, rooms):
      """
      Transform a list of rooms in a dictionary indexed by room id.
      Arguments:
      - floor_id: a string representing the floor identifier,
      - rooms: a list of rooms.
      Returns: a dictionary of rooms.
      Validate the r_id using Building.is_valid_rid function and discard rooms
      with invalid id. Create and return a dictionary of validated rooms.
      """
      result = {}
      discarded_rooms = set()

      for r in map(self.sanitize_room, rooms):
         if not Building.is_valid_rid(r["r_id"]):
            discarded_rooms.add(r["r_id"])
            continue

         if "cat_id" in r:
            r["cat_id"] = RoomCategory.get_cat_id_by_name(r.get("cat_name", ""))
            del r["cat_name"]
         r_id = r["r_id"]
         del r["r_id"]
         result[r_id] = r

      if discarded_rooms:
         Logger.warning(
            "Rooms discarded from floor", floor_id,
            "for having an invalid room id:",
            ", ".join(discarded_rooms)
            )
      return result
开发者ID:khamusa,项目名称:spazi-unimi,代码行数:32,代码来源:room_data_updater.py


示例7: __monkey_checker

    def __monkey_checker(self):

        __act = self.__android_helper.getCurAct()
        __app = self.__android_helper.getCurApp()
        Logger.d("App: %s, Act: %s " % (__act, __app))

        # 第一次进入,设置Act为当前Act
        if self.__current_act == '':
            self.__current_act = __act
            self.__max_thinking_time = SETTING().get_max_thinging_time()
            self.__think_max_count = random.randint(1, self.__max_thinking_time)
            Logger.d("New Acticity, Max thing time = %s s" % self.__think_max_count)
        #如果两次相同,发送2次Back按键,并设置Act为空
        elif self.__current_act == __act:
            if self.__think_count == self.__think_max_count:
                self.__android_helper.senKey(4)
                self.__android_helper.senKey(4)
                self.__current_act = ''
                self.__think_count = 0
                Logger.d("Seam Acticity Max count: Back.")
            else:
                self.__think_count += 1
                Logger.d("Seam Activity think count " + str(self.__think_count))
        #如果两次不相同,则设置Act为当前act
        else:
            self.__current_act = __act
            self.__max_thinking_time = SETTING().get_max_thinging_time()
            self.__think_max_count = random.randint(1, self.__max_thinking_time)
            self.__think_count = 0
            Logger.d("Diff Activity think count empty, Reset Max thing time = %s s" % self.__think_max_count)
开发者ID:nnmgy,项目名称:MobileAppTest,代码行数:30,代码来源:monkey_checker.py


示例8: resolve_room_categories

    def resolve_room_categories(klass, building, floor_dict=None):
        """
      Given a building, perform the mapping between it's dxf rooms and their
      relative categories.

      It does not save the building, which is responsibility of the caller.

      Arguments:
      - building: a Building object whose dxf rooms we want to process.
      - floor_dict: an (optional) dxf floor to limit the rooms to process. If
      None, all the current building floors will be used instead.

      Returns value: an integer representing the amount of rooms matched. The
      category name saved in place in each room dictionary, under the
      key "cat_name"
      """
        categorized_rooms = 0
        target_floors = floor_dict and [floor_dict] or building.get("dxf") and building.get("dxf")["floors"] or []

        cats = klass.get_room_categories_dict()
        for floor_dict in target_floors:
            categorized_rooms += klass._resolve_room_categories_for_floor(floor_dict, cats)

        if categorized_rooms:
            Logger.info(categorized_rooms, "rooms were categorized")

        return categorized_rooms
开发者ID:khamusa,项目名称:spazi-unimi,代码行数:27,代码来源:dxf_room_cats_resolver.py


示例9: _print_merge_analysis

   def _print_merge_analysis(klass, source, target, building):

      method_name = "analyse_"+source+"_to_"+target
      merge_info  = getattr(FloorMergeAnalysis, method_name)(building)

      if not building.get_path(source+".floors"):
         return

      if not building.get_path(target+".floors"):
         return

      with Logger.info("{} -> {} Merge Analysis".format(source.upper(), target.upper())):
         for f_id, count, which in merge_info:
            total_rooms             = count["total_rooms"]
            identified_rooms        = data_and_percent(count["identified_rooms"], total_rooms)
            non_identified_rooms    = data_and_percent(count["non_identified_rooms"], total_rooms)

            message  = "Floor {:5} | ".format(f_id)
            message += "Rooms: {:<4} | ".format(total_rooms)
            message += "With Id.: {:<12} | ".format(identified_rooms)
            message += "No Id: {:<12}".format(non_identified_rooms)
            with Logger.info(message):
               if count["non_identified_rooms"]:
                  Logger.warning(
                     source,
                     "knows about room(s)",
                     ", ".join(which["non_identified_rooms"]),
                     "but", target, "does not"
                     )
开发者ID:khamusa,项目名称:spazi-unimi,代码行数:29,代码来源:db_analysis.py


示例10: RRApp

class RRApp(object):
    """
    Abstract base class for all rr job renderer aplications.
    """

    def __init__(self):
        self.log = Logger(debug=True)

    def version(self):
        raise NotImplementedError()

    def open_scene(self):
        raise NotImplementedError()

    def set_env(self, name, value):
        if value is not None:
            os.environ[name] = value
            self.log.info('Environmental variable "%s" set to "%s"' % (name, value))
        else:
            self.log.info('Can not set environment "%s" to "%s"' % (name, value))

    def start_kso_server(self):
        """
        This function perform Keep Scene Open RR functionality.
        Start TCP server and listen for commands from client.
        """
        KSO_HOST = "localhost"
        KSO_PORT = 7774
        server = rrKSOServer((KSO_HOST, KSO_PORT), rrKSOTCPHandler)
        server.handle_command()

    def start_render(self):
        raise NotImplementedError()
开发者ID:Kif11,项目名称:rr_render_scripts,代码行数:33,代码来源:application.py


示例11: build_element

    def build_element(link_type, label):

        # find item which is desired
        link_text = None
        if label.find(':') != -1:
            link_text = label[label.find(':') + 1:]
            label = label[:label.find(':')]

        result = Globals.get_url_by_name(label, link_type)
        item = result[0]
        item_field = result[1]
        a = etree.Element('a')
        a.set('data-href', 'Alink')

        if item_field:
            a.text = link_text or item_field.href_name
            a.set('href', '#{item_field.href_id}'.format(item_field=item_field))

        elif item:
            a.text = link_text or item.href_name
            a.set('href', '#{item.href_id}'.format(item=item))
        else:
            Logger.instance().warning('Link not found %s %s' % (link_type, label))
            return ''
        a.set('text', a.text)
        return a
开发者ID:jbrezmorf,项目名称:flow123d,代码行数:26,代码来源:md_links.py


示例12: _run

    def _run(self, timeout):
        timeout = min([max_wait_time, timeout]) * self.scale

        def target():
            Logger.instance().info('Running command with time limit {:1.2f} s: {} in {}'.format(timeout, self.args.command, self.args.cwd))
            self.process = Popen(self.args.command, stdout=self.out, stderr=self.err, stdin=self.inn, cwd=self.args.cwd)
            Logger.instance().info('started PID {}'.format(self.process.pid))
            self.process.wait()  # process itself is not limited but there is global limit
            Logger.instance().info('Command finished with %d' % self.process.returncode)

        thread = threading.Thread(target=target)
        thread.start()
        thread.join(GlobalTimeout.time_left())

        if thread.is_alive():
            Logger.instance().info('Terminating process')
            self.terminated = True
            self.global_terminate = GlobalTimeout.time_left() < 0

            try:
                self.process.terminate()
            except Exception as e:
                print(e)

            try:
                self.process.kill()
            except Exception as e:
                print(e)
            thread.join()
开发者ID:x3mSpeedy,项目名称:tgh-tul-tools,代码行数:29,代码来源:job_processing.py


示例13: subscriptions

def subscriptions(username):
    Logger.log(
        '-------------------------------\n' +
        '         SUBSCRIPTIONS\n' +
        'username: ' + username + '\n' +
        '-------------------------------\n\n',

        Color.GREEN)
开发者ID:tylerbrockett,项目名称:reddit-bot-buildapcsales,代码行数:8,代码来源:output.py


示例14: information_exception

def information_exception(username):
    Logger.log(
        'information exception caught\n' +
        'username:   ' + username + '\n' +
        'stacktrace: ' + '\n' +
        traceback.format_exc() + '\n\n',

        Color.RED)
开发者ID:tylerbrockett,项目名称:reddit-bot-buildapcsales,代码行数:8,代码来源:output.py


示例15: subscriptions_exception

def subscriptions_exception(username):
    Logger.log(
        'subscriptions exception caught\n' +
        'username:   ' + username + '\n' +
        'stacktrace: ' + '\n' +
        traceback.format_exc() + '\n\n',

        Color.RED)
开发者ID:tylerbrockett,项目名称:reddit-bot-buildapcsales,代码行数:8,代码来源:output.py


示例16: unsubscribe_all

def unsubscribe_all(username):
    Logger.log(
        '-------------------------------\n' +
        '         UNSUBSCRIBE ALL\n' +
        'username: ' + username + '\n' +
        '-------------------------------\n\n',

        Color.RED)
开发者ID:tylerbrockett,项目名称:reddit-bot-buildapcsales,代码行数:8,代码来源:output.py


示例17: unsubscribe_all_exception

def unsubscribe_all_exception(username):
    Logger.log(
        'unsubscribe all exception caught\n' +
        'username:   ' + username + '\n' +
        'stacktrace: ' + '\n' +
        traceback.format_exc() + '\n\n',

        Color.RED)
开发者ID:tylerbrockett,项目名称:reddit-bot-buildapcsales,代码行数:8,代码来源:output.py


示例18: information

def information(username):
    Logger.log(
        '-------------------------------\n' +
        '         INFORMATION\n' +
        'username: ' + username + '\n' +
        '-------------------------------\n\n',

        Color.GREEN)
开发者ID:tylerbrockett,项目名称:reddit-bot-buildapcsales,代码行数:8,代码来源:output.py


示例19: check_for_commands

 def check_for_commands(self):
     Logger.log('Checking for commands')
     commands = CommandHandler.get_commands(self.reddit)
     if CommandHandler.PAUSE in commands:
         self.run = False
     if CommandHandler.RUN in commands:
         self.run = True
     if CommandHandler.KILL in commands:
         exit()
开发者ID:tylerbrockett,项目名称:reddit-bot-buildapcsales,代码行数:9,代码来源:alert_bot.py


示例20: get_name

class Valgrind:
    def get_name(self):
        return self.name


    def __init__(self, benchmark_path, log_file_path):
        self.pipeline = MakePipeline(benchmark_path)
        self.name = "Valgrind"
        self.logger = Logger(log_file_path, self.name)
        self.output_dict = {}
        self.tp_set = set([])
        self.fp_set = set([])
        self.neg_count = 0
        os.chdir(os.path.expanduser(benchmark_path))

    def run(self):
        self.pipeline.build_benchmark(CC="gcc", CFLAGS="", LD="gcc")
        self.pipeline.run_bechmark(self, ["valgrind", "--error-exitcode=10"], 6)
        return self.output_dict

    def get_output_dict(self):
        return self.output_dict

    def get_tp_set(self):
        print len(self.tp_set)
        return self.tp_set

    def get_fp_set(self):
        print len(self.fp_set)
        return self.fp_set

    def analyze_output(self, exit_code, stdout, stderr, cur_dir, i, j):
        print(stderr)
        if i not in self.output_dict:
            self.output_dict[i] = {"count": 0, "TP": 0, "FP": 0}
        self.output_dict[i]["count"] += 1
        if exit_code != 0:
            if "w_Defects" in cur_dir:
                self.output_dict[i]["TP"] += 1
                self.logger.log_output(stderr, i, cur_dir, j, "TP")
                self.tp_set.add((i, j))
            else:
                self.output_dict[i]["FP"] += 1
                self.logger.log_output(stderr, i, cur_dir, j, "FP")
                self.fp_set.add((i, j))
        else:
            self.logger.log_output(stdout, i, cur_dir, j, "NEG")

    def analyze_timeout(self, cur_dir, i, j):
        if i not in self.output_dict:
            self.output_dict[i] = {"count": 0, "TP": 0, "FP": 0}
        self.output_dict[i]["count"] += 1
        self.logger.log_output("", i, cur_dir, j, "NEG")

    def cleanup(self):
        self.pipeline.clean_benchmark()
        self.logger.close_log()
开发者ID:osamagid,项目名称:evaluation,代码行数:57,代码来源:valgrind.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python logger_tools.response_with_mimetype_and_name函数代码示例发布时间:2022-05-26
下一篇:
Python logger.info函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap