{"id":15009962,"url":"https://github.com/etuzon/python-nrt-logging","last_synced_at":"2026-01-19T04:02:47.289Z","repository":{"id":61346584,"uuid":"549092819","full_name":"etuzon/python-nrt-logging","owner":"etuzon","description":"Hierarchical logging in yaml format","archived":false,"fork":false,"pushed_at":"2024-04-22T13:29:51.000Z","size":346,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-04-22T13:46:37.580Z","etag":null,"topics":["hierarchical","hierarchy","log","logger","loggers","logging","logging-framework","logging-library","nrt","nrt-logging","python","python-3","python3","yaml"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/etuzon.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-10-10T16:58:51.000Z","updated_at":"2024-04-22T13:29:55.000Z","dependencies_parsed_at":"2024-09-24T19:29:22.111Z","dependency_job_id":"7b30341a-bbd1-42e4-a039-3fa11bb2744c","html_url":"https://github.com/etuzon/python-nrt-logging","commit_stats":{"total_commits":59,"total_committers":4,"mean_commits":14.75,"dds":0.2542372881355932,"last_synced_commit":"54486819b662670a914882265d9d5d32de6300f2"},"previous_names":["etuzon/nrt-logging","etuzon/python-nrt-logging"],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/etuzon%2Fpython-nrt-logging","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/etuzon%2Fpython-nrt-logging/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/etuzon%2Fpython-nrt-logging/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/etuzon%2Fpython-nrt-logging/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/etuzon","download_url":"https://codeload.github.com/etuzon/python-nrt-logging/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247276188,"owners_count":20912288,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hierarchical","hierarchy","log","logger","loggers","logging","logging-framework","logging-library","nrt","nrt-logging","python","python-3","python3","yaml"],"created_at":"2024-09-24T19:29:17.703Z","updated_at":"2026-01-19T04:02:47.277Z","avatar_url":"https://github.com/etuzon.png","language":"Python","readme":"# Hierarchical logging in yaml format.\n\n![PyPI](https://img.shields.io/pypi/v/nrt-logging?color=blueviolet\u0026style=plastic)\n![PyPI - Python Version](https://img.shields.io/pypi/pyversions/nrt-logging?color=greens\u0026style=plastic)\n![PyPI - License](https://img.shields.io/pypi/l/nrt-logging?color=blue\u0026style=plastic)\n![PyPI - Downloads](https://img.shields.io/pypi/dd/nrt-logging?style=plastic)\n![PyPI - Downloads](https://img.shields.io/pypi/dm/nrt-logging?color=yellow\u0026style=plastic)\n[![Coverage Status](https://coveralls.io/repos/github/etuzon/nrt-logging/badge.svg)](https://coveralls.io/github/etuzon/pytohn-nrt-logging)\n![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/etuzon/python-nrt-logging?style=plastic)\n![GitHub last commit](https://img.shields.io/github/last-commit/etuzon/python-nrt-logging?style=plastic)\n[![DeepSource](https://deepsource.io/gh/etuzon/python-nrt-logging.svg/?label=active+issues\u0026token=3pUgM1IEwZG6Gpuc065dKDxM)](https://deepsource.io/gh/etuzon/python-nrt-logging/?ref=repository-badge)\n\nHierarchical logging help to group logs that are related to the same code flow.\n\nLog style can be styled in Yaml format or in Line format.\n\n### Examples:\n\n#### Output in YAML style\n\n```Python\nfrom nrt_logging.logger import NrtLogger\nfrom nrt_logging.logger_manager import logger_manager\nfrom nrt_logging.logger_stream_handlers import ManualDepthEnum\n\nNAME_1 = 'TEST1'\nNAME_2 = 'TEST2'\n\n\nclass Child:\n    __logger: NrtLogger\n\n    def __init__(self):\n        self.__logger = logger_manager.get_logger(NAME_1)\n\n    def child_1(self):\n        self.__logger.info('Child 1')\n        self.child_2()\n\n    def child_2(self):\n        self.__logger.info('Child 2')\n\n\nclass Parent:\n    MSG_1 = 'MSG_1'\n    MSG_2 = 'MSG_2'\n    MSG_3 = 'MSG_3'\n    INCREASE_MSG = 'INCREASE_MSG'\n    DECREASE_MSG = 'DECREASE_MSG'\n\n    __logger: NrtLogger\n    __child: Child\n\n    def __init__(self):\n        self.__logger = logger_manager.get_logger(NAME_1)\n        self.__child = Child()\n\n    def a1(self):\n        self.__logger.warn(self.MSG_1)\n        self.__child.child_1()\n\n    def a2_manual(self):\n        self.__logger.info(self.MSG_2)\n        self.__logger.increase_depth()\n        self.__logger.info(self.INCREASE_MSG)\n        self.__logger.decrease_depth()\n        self.__logger.info(self.DECREASE_MSG)\n        self.__logger.error(self.MSG_1)\n        self.a1()\n\n    def a3_manual(self):\n        self.__logger.info(self.MSG_2)\n        self.__logger.increase_depth()\n        self.__logger.info(self.INCREASE_MSG)\n        self.__logger.decrease_depth()\n        self.__logger.info(self.DECREASE_MSG)\n        self.__logger.error(self.MSG_3)\n\n    def a4_manual(self):\n        self.__logger.info(self.MSG_1)\n        self.__logger.info(self.INCREASE_MSG, ManualDepthEnum.INCREASE)\n        self.__logger.info(self.DECREASE_MSG, ManualDepthEnum.DECREASE)\n        self.__logger.error(self.MSG_2)\n```\n\n```Python\nfrom examples.demo_classes.demo_classes import NAME_1, Parent\nfrom nrt_logging.logger_manager import logger_manager\nfrom nrt_logging.logger_stream_handlers import \\\n    ConsoleStreamHandler, LogStyleEnum\n\n\ndef logging_style(log_style: LogStyleEnum):\n    sh = ConsoleStreamHandler()\n    sh.style = log_style\n    logger = logger_manager.get_logger(NAME_1)\n    logger.add_stream_handler(sh)\n    p = Parent()\n    p.a1()\n\n\ndef logging_line_style():\n    logging_style(LogStyleEnum.LINE)\n\n\ndef logging_yaml_style():\n    logging_style(LogStyleEnum.YAML)\n\n\nlogging_yaml_style()\n```\n\nOutput\n```YAML\n---\ndate: 2022-10-31 17:59:04.653084\nlog_level: WARN\npath: demo_classes.py.Parent\nmethod: a1\nline_number: 38\nmessage: MSG_1\nchildren:\n  - date: 2022-10-31 17:59:04.655071\n    log_level: INFO\n    path: demo_classes.py.Child\n    method: child_1\n    line_number: 16\n    message: Child 1\n    children:\n      - date: 2022-10-31 17:59:04.656137\n        log_level: INFO\n        path: demo_classes.py.Child\n        method: child_2\n        line_number: 20\n        message: Child 2\n```\n\n#### Output in LINE style\n\n```YAML\n- log: 2022-10-31 18:16:54.033735 [WARN] [demo_classes.py.Parent.a1:38] MSG_1\n  children:\n    - log: 2022-10-31 18:16:54.034660 [INFO] [demo_classes.py.Child.child_1:16] Child 1\n      children:\n        - log: 2022-10-31 18:16:54.036723 [INFO] [demo_classes.py.Child.child_2:20] Child 2\n```\n\n```Python\nfrom nrt_logging.log_level import LogLevelEnum\nfrom nrt_logging.logger_manager import logger_manager\nfrom nrt_logging.logger_stream_handlers import \\\n    ConsoleStreamHandler, LogStyleEnum\n\n\nsh = ConsoleStreamHandler()\nsh.log_level = LogLevelEnum.TRACE\nsh.style = LogStyleEnum.LINE\nlogger = logger_manager.get_logger('NAME_1')\nlogger.add_stream_handler(sh)\n\nlogger.info('main level log')\nlogger.increase_depth()\nlogger.info('child 1')\nlogger.increase_depth()\nlogger.info('child 1_1')\nlogger.decrease_depth()\nlogger.info('child 2')\nlogger.decrease_depth()\nlogger.info('continue main level')\n```\n\nOutput\n```YAML\n- log: 2022-10-31 18:18:34.520544 [INFO] [manual_hierarchy_line_logging_1.py.\u003cmodule\u003e:13] main level log\n  children:\n    - log: 2022-10-31 18:18:34.522606 [INFO] [manual_hierarchy_line_logging_1.py.\u003cmodule\u003e:15] child 1\n      children:\n        - log: 2022-10-31 18:18:34.523784 [INFO] [manual_hierarchy_line_logging_1.py.\u003cmodule\u003e:17] child 1_1\n- log: 2022-10-31 18:18:34.524810 [INFO] [manual_hierarchy_line_logging_1.py.\u003cmodule\u003e:19] child 2\n- log: 2022-10-31 18:18:34.525864 [INFO] [manual_hierarchy_line_logging_1.py.\u003cmodule\u003e:21] continue main level\n```\n\n### Config file\n\nlog_manager config file in YAML style.\u003cbr\u003e\nConfigure loggers and stream handlers.\n\nparameters are inherited. Parameters that are deeper in YAML file will be taken.\n\n```YAML\nlog_level: WARN\ndate_format: '%Y-%m-%d %H:%M:%S'\nloggers:\n  - name: TEST1\n    style: yaml\n    log_line_template: '[$log_level$] \u003c$date$\u003e $message$'\n    stream_handlers:\n      - type: console\n        style: line\n      - type: file\n        file_path: logs/log_test_1.txt\n        log_level: DEBUG\n        style: line\n        date_format: '%Y'\n        log_line_template: 'Test1 $date$ $message$'\n  - name: TEST2\n    style: yaml\n    stream_handlers:\n      - type: file\n        file_path: logs/log_test_2.txt\n        log_level: ERROR\n        date_format: '%Y'\n        log_yaml_elements:\n          ['log_level', 'date', 'message']\n```\n\n```Python\nfrom nrt_logging.logger_manager import logger_manager\n\n\nCONFIG_FILE_PATH = './config/config1.yaml'\n\nlogger_manager.set_config(file_path=CONFIG_FILE_PATH)\n```\n\nWiki: https://github.com/etuzon/nrt-logging/wiki\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fetuzon%2Fpython-nrt-logging","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fetuzon%2Fpython-nrt-logging","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fetuzon%2Fpython-nrt-logging/lists"}