Repository files navigation

Hierarchical logging in yaml format.

PyPIPyPI - Python VersionPyPI - LicensePyPI - DownloadsPyPI - DownloadsCoverage StatusGitHub code size in bytesGitHub last commitDeepSource

Hierarchical logging help to group logs that are related to the same code flow.

Log style can be styled in Yaml format or in Line format.

Examples:

Output in YAML style

fromnrt_logging.loggerimportNrtLoggerfromnrt_logging.logger_managerimportlogger_managerfromnrt_logging.logger_stream_handlersimportManualDepthEnumNAME_1='TEST1'NAME_2='TEST2'classChild:
__logger: NrtLoggerdef__init__(self):
self.__logger=logger_manager.get_logger(NAME_1)
defchild_1(self):
self.__logger.info('Child 1')
self.child_2()
defchild_2(self):
self.__logger.info('Child 2')
classParent:
MSG_1='MSG_1'MSG_2='MSG_2'MSG_3='MSG_3'INCREASE_MSG='INCREASE_MSG'DECREASE_MSG='DECREASE_MSG'__logger: NrtLogger__child: Childdef__init__(self):
self.__logger=logger_manager.get_logger(NAME_1)
self.__child=Child()
defa1(self):
self.__logger.warn(self.MSG_1)
self.__child.child_1()
defa2_manual(self):
self.__logger.info(self.MSG_2)
self.__logger.increase_depth()
self.__logger.info(self.INCREASE_MSG)
self.__logger.decrease_depth()
self.__logger.info(self.DECREASE_MSG)
self.__logger.error(self.MSG_1)
self.a1()
defa3_manual(self):
self.__logger.info(self.MSG_2)
self.__logger.increase_depth()
self.__logger.info(self.INCREASE_MSG)
self.__logger.decrease_depth()
self.__logger.info(self.DECREASE_MSG)
self.__logger.error(self.MSG_3)
defa4_manual(self):
self.__logger.info(self.MSG_1)
self.__logger.info(self.INCREASE_MSG, ManualDepthEnum.INCREASE)
self.__logger.info(self.DECREASE_MSG, ManualDepthEnum.DECREASE)
self.__logger.error(self.MSG_2)
fromexamples.demo_classes.demo_classesimportNAME_1, Parentfromnrt_logging.logger_managerimportlogger_managerfromnrt_logging.logger_stream_handlersimport \
ConsoleStreamHandler, LogStyleEnumdeflogging_style(log_style: LogStyleEnum):
sh=ConsoleStreamHandler()
sh.style=log_stylelogger=logger_manager.get_logger(NAME_1)
logger.add_stream_handler(sh)
p=Parent()
p.a1()
deflogging_line_style():
logging_style(LogStyleEnum.LINE)
deflogging_yaml_style():
logging_style(LogStyleEnum.YAML)
logging_yaml_style()

Output

---
date: 2022-10-31 17:59:04.653084log_level: WARNpath: demo_classes.py.Parentmethod: a1line_number: 38message: MSG_1children:
- date: 2022-10-31 17:59:04.655071log_level: INFOpath: demo_classes.py.Childmethod: child_1line_number: 16message: Child 1children:
- date: 2022-10-31 17:59:04.656137log_level: INFOpath: demo_classes.py.Childmethod: child_2line_number: 20message: Child 2

Output in LINE style

- log: 2022-10-31 18:16:54.033735 [WARN] [demo_classes.py.Parent.a1:38] MSG_1children:
- log: 2022-10-31 18:16:54.034660 [INFO] [demo_classes.py.Child.child_1:16] Child 1children:
- log: 2022-10-31 18:16:54.036723 [INFO] [demo_classes.py.Child.child_2:20] Child 2
fromnrt_logging.log_levelimportLogLevelEnumfromnrt_logging.logger_managerimportlogger_managerfromnrt_logging.logger_stream_handlersimport \
ConsoleStreamHandler, LogStyleEnumsh=ConsoleStreamHandler()
sh.log_level=LogLevelEnum.TRACEsh.style=LogStyleEnum.LINElogger=logger_manager.get_logger('NAME_1')
logger.add_stream_handler(sh)
logger.info('main level log')
logger.increase_depth()
logger.info('child 1')
logger.increase_depth()
logger.info('child 1_1')
logger.decrease_depth()
logger.info('child 2')
logger.decrease_depth()
logger.info('continue main level')

Output

- log: 2022-10-31 18:18:34.520544 [INFO] [manual_hierarchy_line_logging_1.py.<module>:13] main level logchildren:
- log: 2022-10-31 18:18:34.522606 [INFO] [manual_hierarchy_line_logging_1.py.<module>:15] child 1children:
- log: 2022-10-31 18:18:34.523784 [INFO] [manual_hierarchy_line_logging_1.py.<module>:17] child 1_1
- log: 2022-10-31 18:18:34.524810 [INFO] [manual_hierarchy_line_logging_1.py.<module>:19] child 2
- log: 2022-10-31 18:18:34.525864 [INFO] [manual_hierarchy_line_logging_1.py.<module>:21] continue main level

Config file

log_manager config file in YAML style.
Configure loggers and stream handlers.

parameters are inherited. Parameters that are deeper in YAML file will be taken.

log_level: WARNdate_format: '%Y-%m-%d %H:%M:%S'loggers:
- name: TEST1style: yamllog_line_template: '[$log_level$] <$date$> $message$'stream_handlers:
- type: consolestyle: line
- type: filefile_path: logs/log_test_1.txtlog_level: DEBUGstyle: linedate_format: '%Y'log_line_template: 'Test1 $date$ $message$'
- name: TEST2style: yamlstream_handlers:
- type: filefile_path: logs/log_test_2.txtlog_level: ERRORdate_format: '%Y'log_yaml_elements:
['log_level', 'date', 'message']
fromnrt_logging.logger_managerimportlogger_managerCONFIG_FILE_PATH='./config/config1.yaml'logger_manager.set_config(file_path=CONFIG_FILE_PATH)

Wiki: https://github.com/etuzon/nrt-logging/wiki

Releases

Packages

Used by

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Add copy buttons to all
 blocks\n(function() {\n function addCopyButtons() {\n document.querySelectorAll('pre code').forEach(function(codeBlock) {\n if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;\n codeBlock.parentElement.setAttribute('data-copy-added', 'true');\n \n var btn = document.createElement('button');\n btn.textContent = 'Copy';\n btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';\n btn.onmouseover = function() { this.style.opacity = '1'; };\n btn.onmouseout = function() { this.style.opacity = '0.7'; };\n btn.onclick = function() {\n navigator.clipboard.writeText(codeBlock.textContent).then(function() {\n btn.textContent = 'Copied!';\n setTimeout(function() { btn.textContent = 'Copy'; }, 1500);\n });\n };\n codeBlock.parentElement.style.position = 'relative';\n codeBlock.parentElement.appendChild(btn);\n });\n }\n \n addCopyButtons();\n \n // Re-run on dynamic content\n var observer = new MutationObserver(addCopyButtons);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Add Copy Buttons to Code Blocks");
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Skip to content

Repository files navigation

Hierarchical logging in yaml format.

PyPIPyPI - Python VersionPyPI - LicensePyPI - DownloadsPyPI - DownloadsCoverage StatusGitHub code size in bytesGitHub last commitDeepSource

Hierarchical logging help to group logs that are related to the same code flow.

Log style can be styled in Yaml format or in Line format.

Examples:

Output in YAML style

fromnrt_logging.loggerimportNrtLoggerfromnrt_logging.logger_managerimportlogger_managerfromnrt_logging.logger_stream_handlersimportManualDepthEnumNAME_1='TEST1'NAME_2='TEST2'classChild:
__logger: NrtLoggerdef__init__(self):
self.__logger=logger_manager.get_logger(NAME_1)
defchild_1(self):
self.__logger.info('Child 1')
self.child_2()
defchild_2(self):
self.__logger.info('Child 2')
classParent:
MSG_1='MSG_1'MSG_2='MSG_2'MSG_3='MSG_3'INCREASE_MSG='INCREASE_MSG'DECREASE_MSG='DECREASE_MSG'__logger: NrtLogger__child: Childdef__init__(self):
self.__logger=logger_manager.get_logger(NAME_1)
self.__child=Child()
defa1(self):
self.__logger.warn(self.MSG_1)
self.__child.child_1()
defa2_manual(self):
self.__logger.info(self.MSG_2)
self.__logger.increase_depth()
self.__logger.info(self.INCREASE_MSG)
self.__logger.decrease_depth()
self.__logger.info(self.DECREASE_MSG)
self.__logger.error(self.MSG_1)
self.a1()
defa3_manual(self):
self.__logger.info(self.MSG_2)
self.__logger.increase_depth()
self.__logger.info(self.INCREASE_MSG)
self.__logger.decrease_depth()
self.__logger.info(self.DECREASE_MSG)
self.__logger.error(self.MSG_3)
defa4_manual(self):
self.__logger.info(self.MSG_1)
self.__logger.info(self.INCREASE_MSG, ManualDepthEnum.INCREASE)
self.__logger.info(self.DECREASE_MSG, ManualDepthEnum.DECREASE)
self.__logger.error(self.MSG_2)
fromexamples.demo_classes.demo_classesimportNAME_1, Parentfromnrt_logging.logger_managerimportlogger_managerfromnrt_logging.logger_stream_handlersimport \
ConsoleStreamHandler, LogStyleEnumdeflogging_style(log_style: LogStyleEnum):
sh=ConsoleStreamHandler()
sh.style=log_stylelogger=logger_manager.get_logger(NAME_1)
logger.add_stream_handler(sh)
p=Parent()
p.a1()
deflogging_line_style():
logging_style(LogStyleEnum.LINE)
deflogging_yaml_style():
logging_style(LogStyleEnum.YAML)
logging_yaml_style()

Output

---
date: 2022-10-31 17:59:04.653084log_level: WARNpath: demo_classes.py.Parentmethod: a1line_number: 38message: MSG_1children:
- date: 2022-10-31 17:59:04.655071log_level: INFOpath: demo_classes.py.Childmethod: child_1line_number: 16message: Child 1children:
- date: 2022-10-31 17:59:04.656137log_level: INFOpath: demo_classes.py.Childmethod: child_2line_number: 20message: Child 2

Output in LINE style

- log: 2022-10-31 18:16:54.033735 [WARN] [demo_classes.py.Parent.a1:38] MSG_1children:
- log: 2022-10-31 18:16:54.034660 [INFO] [demo_classes.py.Child.child_1:16] Child 1children:
- log: 2022-10-31 18:16:54.036723 [INFO] [demo_classes.py.Child.child_2:20] Child 2
fromnrt_logging.log_levelimportLogLevelEnumfromnrt_logging.logger_managerimportlogger_managerfromnrt_logging.logger_stream_handlersimport \
ConsoleStreamHandler, LogStyleEnumsh=ConsoleStreamHandler()
sh.log_level=LogLevelEnum.TRACEsh.style=LogStyleEnum.LINElogger=logger_manager.get_logger('NAME_1')
logger.add_stream_handler(sh)
logger.info('main level log')
logger.increase_depth()
logger.info('child 1')
logger.increase_depth()
logger.info('child 1_1')
logger.decrease_depth()
logger.info('child 2')
logger.decrease_depth()
logger.info('continue main level')

Output

- log: 2022-10-31 18:18:34.520544 [INFO] [manual_hierarchy_line_logging_1.py.<module>:13] main level logchildren:
- log: 2022-10-31 18:18:34.522606 [INFO] [manual_hierarchy_line_logging_1.py.<module>:15] child 1children:
- log: 2022-10-31 18:18:34.523784 [INFO] [manual_hierarchy_line_logging_1.py.<module>:17] child 1_1
- log: 2022-10-31 18:18:34.524810 [INFO] [manual_hierarchy_line_logging_1.py.<module>:19] child 2
- log: 2022-10-31 18:18:34.525864 [INFO] [manual_hierarchy_line_logging_1.py.<module>:21] continue main level

Config file

log_manager config file in YAML style.
Configure loggers and stream handlers.

parameters are inherited. Parameters that are deeper in YAML file will be taken.

log_level: WARNdate_format: '%Y-%m-%d %H:%M:%S'loggers:
- name: TEST1style: yamllog_line_template: '[$log_level$] <$date$> $message$'stream_handlers:
- type: consolestyle: line
- type: filefile_path: logs/log_test_1.txtlog_level: DEBUGstyle: linedate_format: '%Y'log_line_template: 'Test1 $date$ $message$'
- name: TEST2style: yamlstream_handlers:
- type: filefile_path: logs/log_test_2.txtlog_level: ERRORdate_format: '%Y'log_yaml_elements:
['log_level', 'date', 'message']
fromnrt_logging.logger_managerimportlogger_managerCONFIG_FILE_PATH='./config/config1.yaml'logger_manager.set_config(file_path=CONFIG_FILE_PATH)

Wiki: https://github.com/etuzon/nrt-logging/wiki

Releases

Packages

Used by

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Force GitHub README to respect dark mode\n(function() {\n var style = document.createElement('style');\n style.textContent = '\n .markdown-body {\n color-scheme: dark light;\n }\n .markdown-body pre { background: #161b22 !important; }\n .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; }\n .markdown-body table th, .markdown-body table td { border-color: #30363d !important; }\n .markdown-body img { background: #0d1117; }\n .markdown-body blockquote { border-left-color: #8b949e; }\n .markdown-body hr { border-color: #30363d; }\n ';\n document.head.appendChild(style);\n})();", "GitHub Dark Mode README Fix"); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Repository files navigation

Hierarchical logging in yaml format.

PyPIPyPI - Python VersionPyPI - LicensePyPI - DownloadsPyPI - DownloadsCoverage StatusGitHub code size in bytesGitHub last commitDeepSource

Hierarchical logging help to group logs that are related to the same code flow.

Log style can be styled in Yaml format or in Line format.

Examples:

Output in YAML style

fromnrt_logging.loggerimportNrtLoggerfromnrt_logging.logger_managerimportlogger_managerfromnrt_logging.logger_stream_handlersimportManualDepthEnumNAME_1='TEST1'NAME_2='TEST2'classChild:
__logger: NrtLoggerdef__init__(self):
self.__logger=logger_manager.get_logger(NAME_1)
defchild_1(self):
self.__logger.info('Child 1')
self.child_2()
defchild_2(self):
self.__logger.info('Child 2')
classParent:
MSG_1='MSG_1'MSG_2='MSG_2'MSG_3='MSG_3'INCREASE_MSG='INCREASE_MSG'DECREASE_MSG='DECREASE_MSG'__logger: NrtLogger__child: Childdef__init__(self):
self.__logger=logger_manager.get_logger(NAME_1)
self.__child=Child()
defa1(self):
self.__logger.warn(self.MSG_1)
self.__child.child_1()
defa2_manual(self):
self.__logger.info(self.MSG_2)
self.__logger.increase_depth()
self.__logger.info(self.INCREASE_MSG)
self.__logger.decrease_depth()
self.__logger.info(self.DECREASE_MSG)
self.__logger.error(self.MSG_1)
self.a1()
defa3_manual(self):
self.__logger.info(self.MSG_2)
self.__logger.increase_depth()
self.__logger.info(self.INCREASE_MSG)
self.__logger.decrease_depth()
self.__logger.info(self.DECREASE_MSG)
self.__logger.error(self.MSG_3)
defa4_manual(self):
self.__logger.info(self.MSG_1)
self.__logger.info(self.INCREASE_MSG, ManualDepthEnum.INCREASE)
self.__logger.info(self.DECREASE_MSG, ManualDepthEnum.DECREASE)
self.__logger.error(self.MSG_2)
fromexamples.demo_classes.demo_classesimportNAME_1, Parentfromnrt_logging.logger_managerimportlogger_managerfromnrt_logging.logger_stream_handlersimport \
ConsoleStreamHandler, LogStyleEnumdeflogging_style(log_style: LogStyleEnum):
sh=ConsoleStreamHandler()
sh.style=log_stylelogger=logger_manager.get_logger(NAME_1)
logger.add_stream_handler(sh)
p=Parent()
p.a1()
deflogging_line_style():
logging_style(LogStyleEnum.LINE)
deflogging_yaml_style():
logging_style(LogStyleEnum.YAML)
logging_yaml_style()

Output

---
date: 2022-10-31 17:59:04.653084log_level: WARNpath: demo_classes.py.Parentmethod: a1line_number: 38message: MSG_1children:
- date: 2022-10-31 17:59:04.655071log_level: INFOpath: demo_classes.py.Childmethod: child_1line_number: 16message: Child 1children:
- date: 2022-10-31 17:59:04.656137log_level: INFOpath: demo_classes.py.Childmethod: child_2line_number: 20message: Child 2

Output in LINE style

- log: 2022-10-31 18:16:54.033735 [WARN] [demo_classes.py.Parent.a1:38] MSG_1children:
- log: 2022-10-31 18:16:54.034660 [INFO] [demo_classes.py.Child.child_1:16] Child 1children:
- log: 2022-10-31 18:16:54.036723 [INFO] [demo_classes.py.Child.child_2:20] Child 2
fromnrt_logging.log_levelimportLogLevelEnumfromnrt_logging.logger_managerimportlogger_managerfromnrt_logging.logger_stream_handlersimport \
ConsoleStreamHandler, LogStyleEnumsh=ConsoleStreamHandler()
sh.log_level=LogLevelEnum.TRACEsh.style=LogStyleEnum.LINElogger=logger_manager.get_logger('NAME_1')
logger.add_stream_handler(sh)
logger.info('main level log')
logger.increase_depth()
logger.info('child 1')
logger.increase_depth()
logger.info('child 1_1')
logger.decrease_depth()
logger.info('child 2')
logger.decrease_depth()
logger.info('continue main level')

Output

- log: 2022-10-31 18:18:34.520544 [INFO] [manual_hierarchy_line_logging_1.py.<module>:13] main level logchildren:
- log: 2022-10-31 18:18:34.522606 [INFO] [manual_hierarchy_line_logging_1.py.<module>:15] child 1children:
- log: 2022-10-31 18:18:34.523784 [INFO] [manual_hierarchy_line_logging_1.py.<module>:17] child 1_1
- log: 2022-10-31 18:18:34.524810 [INFO] [manual_hierarchy_line_logging_1.py.<module>:19] child 2
- log: 2022-10-31 18:18:34.525864 [INFO] [manual_hierarchy_line_logging_1.py.<module>:21] continue main level

Config file

log_manager config file in YAML style.
Configure loggers and stream handlers.

parameters are inherited. Parameters that are deeper in YAML file will be taken.

log_level: WARNdate_format: '%Y-%m-%d %H:%M:%S'loggers:
- name: TEST1style: yamllog_line_template: '[$log_level$] <$date$> $message$'stream_handlers:
- type: consolestyle: line
- type: filefile_path: logs/log_test_1.txtlog_level: DEBUGstyle: linedate_format: '%Y'log_line_template: 'Test1 $date$ $message$'
- name: TEST2style: yamlstream_handlers:
- type: filefile_path: logs/log_test_2.txtlog_level: ERRORdate_format: '%Y'log_yaml_elements:
['log_level', 'date', 'message']
fromnrt_logging.logger_managerimportlogger_managerCONFIG_FILE_PATH='./config/config1.yaml'logger_manager.set_config(file_path=CONFIG_FILE_PATH)

Wiki: https://github.com/etuzon/nrt-logging/wiki

Releases

Packages

Used by

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Highlight search terms from Google/DuckDuckGo/Bing referrer\n(function() {\n var ref = document.referrer;\n var terms = [];\n \n if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) {\n var url = new URL(ref);\n var q = url.searchParams.get('q') || url.searchParams.get('p');\n if (q) {\n terms = q.split(/\\s+/).filter(function(t) { return t.length > 2; });\n }\n }\n \n if (terms.length === 0) return;\n \n var style = document.createElement('style');\n style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }';\n document.head.appendChild(style);\n \n function highlight(node) {\n if (node.nodeType === 3) { // text node\n var text = node.textContent;\n var found = false;\n terms.forEach(function(term) {\n var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\') + ')', 'gi');\n if (regex.test(text)) {\n found = true;\n var frag = document.createDocumentFragment();\n var parts = text.split(regex);\n parts.forEach(function(part, i) {\n if (i % 2 === 0) {\n frag.appendChild(document.createTextNode(part));\n } else {\n var span = document.createElement('span');\n span.className = 'userscript-highlight';\n span.textContent = part;\n frag.appendChild(span);\n }\n });\n node.parentNode.replaceChild(frag, node);\n }\n });\n } else if (node.nodeType === 1 && node.childNodes) { // element\n var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT'];\n if (!skipTags.includes(node.tagName)) {\n Array.from(node.childNodes).forEach(highlight);\n }\n }\n }\n \n highlight(document.body);\n \n // Re-highlight on dynamic content\n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1 || node.nodeType === 3) highlight(node);\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Highlight Search Terms"); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Repository files navigation

Hierarchical logging in yaml format.

PyPIPyPI - Python VersionPyPI - LicensePyPI - DownloadsPyPI - DownloadsCoverage StatusGitHub code size in bytesGitHub last commitDeepSource

Hierarchical logging help to group logs that are related to the same code flow.

Log style can be styled in Yaml format or in Line format.

Examples:

Output in YAML style

fromnrt_logging.loggerimportNrtLoggerfromnrt_logging.logger_managerimportlogger_managerfromnrt_logging.logger_stream_handlersimportManualDepthEnumNAME_1='TEST1'NAME_2='TEST2'classChild:
__logger: NrtLoggerdef__init__(self):
self.__logger=logger_manager.get_logger(NAME_1)
defchild_1(self):
self.__logger.info('Child 1')
self.child_2()
defchild_2(self):
self.__logger.info('Child 2')
classParent:
MSG_1='MSG_1'MSG_2='MSG_2'MSG_3='MSG_3'INCREASE_MSG='INCREASE_MSG'DECREASE_MSG='DECREASE_MSG'__logger: NrtLogger__child: Childdef__init__(self):
self.__logger=logger_manager.get_logger(NAME_1)
self.__child=Child()
defa1(self):
self.__logger.warn(self.MSG_1)
self.__child.child_1()
defa2_manual(self):
self.__logger.info(self.MSG_2)
self.__logger.increase_depth()
self.__logger.info(self.INCREASE_MSG)
self.__logger.decrease_depth()
self.__logger.info(self.DECREASE_MSG)
self.__logger.error(self.MSG_1)
self.a1()
defa3_manual(self):
self.__logger.info(self.MSG_2)
self.__logger.increase_depth()
self.__logger.info(self.INCREASE_MSG)
self.__logger.decrease_depth()
self.__logger.info(self.DECREASE_MSG)
self.__logger.error(self.MSG_3)
defa4_manual(self):
self.__logger.info(self.MSG_1)
self.__logger.info(self.INCREASE_MSG, ManualDepthEnum.INCREASE)
self.__logger.info(self.DECREASE_MSG, ManualDepthEnum.DECREASE)
self.__logger.error(self.MSG_2)
fromexamples.demo_classes.demo_classesimportNAME_1, Parentfromnrt_logging.logger_managerimportlogger_managerfromnrt_logging.logger_stream_handlersimport \
ConsoleStreamHandler, LogStyleEnumdeflogging_style(log_style: LogStyleEnum):
sh=ConsoleStreamHandler()
sh.style=log_stylelogger=logger_manager.get_logger(NAME_1)
logger.add_stream_handler(sh)
p=Parent()
p.a1()
deflogging_line_style():
logging_style(LogStyleEnum.LINE)
deflogging_yaml_style():
logging_style(LogStyleEnum.YAML)
logging_yaml_style()

Output

---
date: 2022-10-31 17:59:04.653084log_level: WARNpath: demo_classes.py.Parentmethod: a1line_number: 38message: MSG_1children:
- date: 2022-10-31 17:59:04.655071log_level: INFOpath: demo_classes.py.Childmethod: child_1line_number: 16message: Child 1children:
- date: 2022-10-31 17:59:04.656137log_level: INFOpath: demo_classes.py.Childmethod: child_2line_number: 20message: Child 2

Output in LINE style

- log: 2022-10-31 18:16:54.033735 [WARN] [demo_classes.py.Parent.a1:38] MSG_1children:
- log: 2022-10-31 18:16:54.034660 [INFO] [demo_classes.py.Child.child_1:16] Child 1children:
- log: 2022-10-31 18:16:54.036723 [INFO] [demo_classes.py.Child.child_2:20] Child 2
fromnrt_logging.log_levelimportLogLevelEnumfromnrt_logging.logger_managerimportlogger_managerfromnrt_logging.logger_stream_handlersimport \
ConsoleStreamHandler, LogStyleEnumsh=ConsoleStreamHandler()
sh.log_level=LogLevelEnum.TRACEsh.style=LogStyleEnum.LINElogger=logger_manager.get_logger('NAME_1')
logger.add_stream_handler(sh)
logger.info('main level log')
logger.increase_depth()
logger.info('child 1')
logger.increase_depth()
logger.info('child 1_1')
logger.decrease_depth()
logger.info('child 2')
logger.decrease_depth()
logger.info('continue main level')

Output

- log: 2022-10-31 18:18:34.520544 [INFO] [manual_hierarchy_line_logging_1.py.<module>:13] main level logchildren:
- log: 2022-10-31 18:18:34.522606 [INFO] [manual_hierarchy_line_logging_1.py.<module>:15] child 1children:
- log: 2022-10-31 18:18:34.523784 [INFO] [manual_hierarchy_line_logging_1.py.<module>:17] child 1_1
- log: 2022-10-31 18:18:34.524810 [INFO] [manual_hierarchy_line_logging_1.py.<module>:19] child 2
- log: 2022-10-31 18:18:34.525864 [INFO] [manual_hierarchy_line_logging_1.py.<module>:21] continue main level

Config file

log_manager config file in YAML style.
Configure loggers and stream handlers.

parameters are inherited. Parameters that are deeper in YAML file will be taken.

log_level: WARNdate_format: '%Y-%m-%d %H:%M:%S'loggers:
- name: TEST1style: yamllog_line_template: '[$log_level$] <$date$> $message$'stream_handlers:
- type: consolestyle: line
- type: filefile_path: logs/log_test_1.txtlog_level: DEBUGstyle: linedate_format: '%Y'log_line_template: 'Test1 $date$ $message$'
- name: TEST2style: yamlstream_handlers:
- type: filefile_path: logs/log_test_2.txtlog_level: ERRORdate_format: '%Y'log_yaml_elements:
['log_level', 'date', 'message']
fromnrt_logging.logger_managerimportlogger_managerCONFIG_FILE_PATH='./config/config1.yaml'logger_manager.set_config(file_path=CONFIG_FILE_PATH)

Wiki: https://github.com/etuzon/nrt-logging/wiki

Releases

Packages

Used by

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Strip utm_, fbclid, gclid, etc. from all links on page\n(function() {\n var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content',\n 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid',\n 'ref', 'ref_src', 'source', 'medium', 'campaign'];\n \n function cleanUrl(url) {\n try {\n var u = new URL(url, window.location.origin);\n var changed = false;\n trackingParams.forEach(function(p) {\n if (u.searchParams.has(p)) {\n u.searchParams.delete(p);\n changed = true;\n }\n });\n return changed ? u.toString() : url;\n } catch (e) {\n return url;\n }\n }\n \n function cleanLinks() {\n document.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n \n cleanLinks();\n \n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1) {\n if (node.tagName === 'A') cleanLinks();\n node.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Remove Tracking Parameters from Links"); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + '
Skip to content

Repository files navigation

Hierarchical logging in yaml format.

PyPIPyPI - Python VersionPyPI - LicensePyPI - DownloadsPyPI - DownloadsCoverage StatusGitHub code size in bytesGitHub last commitDeepSource

Hierarchical logging help to group logs that are related to the same code flow.

Log style can be styled in Yaml format or in Line format.

Examples:

Output in YAML style

fromnrt_logging.loggerimportNrtLoggerfromnrt_logging.logger_managerimportlogger_managerfromnrt_logging.logger_stream_handlersimportManualDepthEnumNAME_1='TEST1'NAME_2='TEST2'classChild:
__logger: NrtLoggerdef__init__(self):
self.__logger=logger_manager.get_logger(NAME_1)
defchild_1(self):
self.__logger.info('Child 1')
self.child_2()
defchild_2(self):
self.__logger.info('Child 2')
classParent:
MSG_1='MSG_1'MSG_2='MSG_2'MSG_3='MSG_3'INCREASE_MSG='INCREASE_MSG'DECREASE_MSG='DECREASE_MSG'__logger: NrtLogger__child: Childdef__init__(self):
self.__logger=logger_manager.get_logger(NAME_1)
self.__child=Child()
defa1(self):
self.__logger.warn(self.MSG_1)
self.__child.child_1()
defa2_manual(self):
self.__logger.info(self.MSG_2)
self.__logger.increase_depth()
self.__logger.info(self.INCREASE_MSG)
self.__logger.decrease_depth()
self.__logger.info(self.DECREASE_MSG)
self.__logger.error(self.MSG_1)
self.a1()
defa3_manual(self):
self.__logger.info(self.MSG_2)
self.__logger.increase_depth()
self.__logger.info(self.INCREASE_MSG)
self.__logger.decrease_depth()
self.__logger.info(self.DECREASE_MSG)
self.__logger.error(self.MSG_3)
defa4_manual(self):
self.__logger.info(self.MSG_1)
self.__logger.info(self.INCREASE_MSG, ManualDepthEnum.INCREASE)
self.__logger.info(self.DECREASE_MSG, ManualDepthEnum.DECREASE)
self.__logger.error(self.MSG_2)
fromexamples.demo_classes.demo_classesimportNAME_1, Parentfromnrt_logging.logger_managerimportlogger_managerfromnrt_logging.logger_stream_handlersimport \
ConsoleStreamHandler, LogStyleEnumdeflogging_style(log_style: LogStyleEnum):
sh=ConsoleStreamHandler()
sh.style=log_stylelogger=logger_manager.get_logger(NAME_1)
logger.add_stream_handler(sh)
p=Parent()
p.a1()
deflogging_line_style():
logging_style(LogStyleEnum.LINE)
deflogging_yaml_style():
logging_style(LogStyleEnum.YAML)
logging_yaml_style()

Output

---
date: 2022-10-31 17:59:04.653084log_level: WARNpath: demo_classes.py.Parentmethod: a1line_number: 38message: MSG_1children:
- date: 2022-10-31 17:59:04.655071log_level: INFOpath: demo_classes.py.Childmethod: child_1line_number: 16message: Child 1children:
- date: 2022-10-31 17:59:04.656137log_level: INFOpath: demo_classes.py.Childmethod: child_2line_number: 20message: Child 2

Output in LINE style

- log: 2022-10-31 18:16:54.033735 [WARN] [demo_classes.py.Parent.a1:38] MSG_1children:
- log: 2022-10-31 18:16:54.034660 [INFO] [demo_classes.py.Child.child_1:16] Child 1children:
- log: 2022-10-31 18:16:54.036723 [INFO] [demo_classes.py.Child.child_2:20] Child 2
fromnrt_logging.log_levelimportLogLevelEnumfromnrt_logging.logger_managerimportlogger_managerfromnrt_logging.logger_stream_handlersimport \
ConsoleStreamHandler, LogStyleEnumsh=ConsoleStreamHandler()
sh.log_level=LogLevelEnum.TRACEsh.style=LogStyleEnum.LINElogger=logger_manager.get_logger('NAME_1')
logger.add_stream_handler(sh)
logger.info('main level log')
logger.increase_depth()
logger.info('child 1')
logger.increase_depth()
logger.info('child 1_1')
logger.decrease_depth()
logger.info('child 2')
logger.decrease_depth()
logger.info('continue main level')

Output

- log: 2022-10-31 18:18:34.520544 [INFO] [manual_hierarchy_line_logging_1.py.<module>:13] main level logchildren:
- log: 2022-10-31 18:18:34.522606 [INFO] [manual_hierarchy_line_logging_1.py.<module>:15] child 1children:
- log: 2022-10-31 18:18:34.523784 [INFO] [manual_hierarchy_line_logging_1.py.<module>:17] child 1_1
- log: 2022-10-31 18:18:34.524810 [INFO] [manual_hierarchy_line_logging_1.py.<module>:19] child 2
- log: 2022-10-31 18:18:34.525864 [INFO] [manual_hierarchy_line_logging_1.py.<module>:21] continue main level

Config file

log_manager config file in YAML style.
Configure loggers and stream handlers.

parameters are inherited. Parameters that are deeper in YAML file will be taken.

log_level: WARNdate_format: '%Y-%m-%d %H:%M:%S'loggers:
- name: TEST1style: yamllog_line_template: '[$log_level$] <$date$> $message$'stream_handlers:
- type: consolestyle: line
- type: filefile_path: logs/log_test_1.txtlog_level: DEBUGstyle: linedate_format: '%Y'log_line_template: 'Test1 $date$ $message$'
- name: TEST2style: yamlstream_handlers:
- type: filefile_path: logs/log_test_2.txtlog_level: ERRORdate_format: '%Y'log_yaml_elements:
['log_level', 'date', 'message']
fromnrt_logging.logger_managerimportlogger_managerCONFIG_FILE_PATH='./config/config1.yaml'logger_manager.set_config(file_path=CONFIG_FILE_PATH)

Wiki: https://github.com/etuzon/nrt-logging/wiki

Releases

Packages

Used by

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Auto-enable theater mode on YouTube\n(function() {\n function tryTheater() {\n var btn = document.querySelector('button[aria-label=\"Theater mode\"], ytd-player #player button[title=\"Theater mode\"]');\n if (btn && !btn.classList.contains('activated')) {\n btn.click();\n }\n }\n \n // Try immediately\n tryTheater();\n \n // Try after navigation (SPA)\n var lastUrl = location.href;\n setInterval(function() {\n if (location.href !== lastUrl) {\n lastUrl = location.href;\n setTimeout(tryTheater, 500);\n }\n }, 1000);\n \n // Also try on player load\n var observer = new MutationObserver(tryTheater);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "YouTube Theater Mode Default"); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Repository files navigation

Hierarchical logging in yaml format.

PyPIPyPI - Python VersionPyPI - LicensePyPI - DownloadsPyPI - DownloadsCoverage StatusGitHub code size in bytesGitHub last commitDeepSource

Hierarchical logging help to group logs that are related to the same code flow.

Log style can be styled in Yaml format or in Line format.

Examples:

Output in YAML style

fromnrt_logging.loggerimportNrtLoggerfromnrt_logging.logger_managerimportlogger_managerfromnrt_logging.logger_stream_handlersimportManualDepthEnumNAME_1='TEST1'NAME_2='TEST2'classChild:
__logger: NrtLoggerdef__init__(self):
self.__logger=logger_manager.get_logger(NAME_1)
defchild_1(self):
self.__logger.info('Child 1')
self.child_2()
defchild_2(self):
self.__logger.info('Child 2')
classParent:
MSG_1='MSG_1'MSG_2='MSG_2'MSG_3='MSG_3'INCREASE_MSG='INCREASE_MSG'DECREASE_MSG='DECREASE_MSG'__logger: NrtLogger__child: Childdef__init__(self):
self.__logger=logger_manager.get_logger(NAME_1)
self.__child=Child()
defa1(self):
self.__logger.warn(self.MSG_1)
self.__child.child_1()
defa2_manual(self):
self.__logger.info(self.MSG_2)
self.__logger.increase_depth()
self.__logger.info(self.INCREASE_MSG)
self.__logger.decrease_depth()
self.__logger.info(self.DECREASE_MSG)
self.__logger.error(self.MSG_1)
self.a1()
defa3_manual(self):
self.__logger.info(self.MSG_2)
self.__logger.increase_depth()
self.__logger.info(self.INCREASE_MSG)
self.__logger.decrease_depth()
self.__logger.info(self.DECREASE_MSG)
self.__logger.error(self.MSG_3)
defa4_manual(self):
self.__logger.info(self.MSG_1)
self.__logger.info(self.INCREASE_MSG, ManualDepthEnum.INCREASE)
self.__logger.info(self.DECREASE_MSG, ManualDepthEnum.DECREASE)
self.__logger.error(self.MSG_2)
fromexamples.demo_classes.demo_classesimportNAME_1, Parentfromnrt_logging.logger_managerimportlogger_managerfromnrt_logging.logger_stream_handlersimport \
ConsoleStreamHandler, LogStyleEnumdeflogging_style(log_style: LogStyleEnum):
sh=ConsoleStreamHandler()
sh.style=log_stylelogger=logger_manager.get_logger(NAME_1)
logger.add_stream_handler(sh)
p=Parent()
p.a1()
deflogging_line_style():
logging_style(LogStyleEnum.LINE)
deflogging_yaml_style():
logging_style(LogStyleEnum.YAML)
logging_yaml_style()

Output

---
date: 2022-10-31 17:59:04.653084log_level: WARNpath: demo_classes.py.Parentmethod: a1line_number: 38message: MSG_1children:
- date: 2022-10-31 17:59:04.655071log_level: INFOpath: demo_classes.py.Childmethod: child_1line_number: 16message: Child 1children:
- date: 2022-10-31 17:59:04.656137log_level: INFOpath: demo_classes.py.Childmethod: child_2line_number: 20message: Child 2

Output in LINE style

- log: 2022-10-31 18:16:54.033735 [WARN] [demo_classes.py.Parent.a1:38] MSG_1children:
- log: 2022-10-31 18:16:54.034660 [INFO] [demo_classes.py.Child.child_1:16] Child 1children:
- log: 2022-10-31 18:16:54.036723 [INFO] [demo_classes.py.Child.child_2:20] Child 2
fromnrt_logging.log_levelimportLogLevelEnumfromnrt_logging.logger_managerimportlogger_managerfromnrt_logging.logger_stream_handlersimport \
ConsoleStreamHandler, LogStyleEnumsh=ConsoleStreamHandler()
sh.log_level=LogLevelEnum.TRACEsh.style=LogStyleEnum.LINElogger=logger_manager.get_logger('NAME_1')
logger.add_stream_handler(sh)
logger.info('main level log')
logger.increase_depth()
logger.info('child 1')
logger.increase_depth()
logger.info('child 1_1')
logger.decrease_depth()
logger.info('child 2')
logger.decrease_depth()
logger.info('continue main level')

Output

- log: 2022-10-31 18:18:34.520544 [INFO] [manual_hierarchy_line_logging_1.py.<module>:13] main level logchildren:
- log: 2022-10-31 18:18:34.522606 [INFO] [manual_hierarchy_line_logging_1.py.<module>:15] child 1children:
- log: 2022-10-31 18:18:34.523784 [INFO] [manual_hierarchy_line_logging_1.py.<module>:17] child 1_1
- log: 2022-10-31 18:18:34.524810 [INFO] [manual_hierarchy_line_logging_1.py.<module>:19] child 2
- log: 2022-10-31 18:18:34.525864 [INFO] [manual_hierarchy_line_logging_1.py.<module>:21] continue main level

Config file

log_manager config file in YAML style.
Configure loggers and stream handlers.

parameters are inherited. Parameters that are deeper in YAML file will be taken.

log_level: WARNdate_format: '%Y-%m-%d %H:%M:%S'loggers:
- name: TEST1style: yamllog_line_template: '[$log_level$] <$date$> $message$'stream_handlers:
- type: consolestyle: line
- type: filefile_path: logs/log_test_1.txtlog_level: DEBUGstyle: linedate_format: '%Y'log_line_template: 'Test1 $date$ $message$'
- name: TEST2style: yamlstream_handlers:
- type: filefile_path: logs/log_test_2.txtlog_level: ERRORdate_format: '%Y'log_yaml_elements:
['log_level', 'date', 'message']
fromnrt_logging.logger_managerimportlogger_managerCONFIG_FILE_PATH='./config/config1.yaml'logger_manager.set_config(file_path=CONFIG_FILE_PATH)

Wiki: https://github.com/etuzon/nrt-logging/wiki

Releases

Packages

Used by

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Remove or un-stick sticky/fixed headers that block content\n(function() {\n function unstick() {\n document.querySelectorAll('header, nav, [role=\"banner\"], .header, .navbar, .sticky, .fixed-top, [style*=\"position: fixed\"], [style*=\"position:sticky\"]').forEach(function(el) {\n if (el.style.position === 'fixed' || el.style.position === 'sticky' || \n getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') {\n el.style.position = 'static';\n el.style.top = 'auto';\n el.style.zIndex = 'auto';\n }\n });\n }\n \n unstick();\n \n var observer = new MutationObserver(unstick);\n observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] });\n})();", "Kill Sticky Headers"); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Repository files navigation

Hierarchical logging in yaml format.

PyPIPyPI - Python VersionPyPI - LicensePyPI - DownloadsPyPI - DownloadsCoverage StatusGitHub code size in bytesGitHub last commitDeepSource

Hierarchical logging help to group logs that are related to the same code flow.

Log style can be styled in Yaml format or in Line format.

Examples:

Output in YAML style

fromnrt_logging.loggerimportNrtLoggerfromnrt_logging.logger_managerimportlogger_managerfromnrt_logging.logger_stream_handlersimportManualDepthEnumNAME_1='TEST1'NAME_2='TEST2'classChild:
__logger: NrtLoggerdef__init__(self):
self.__logger=logger_manager.get_logger(NAME_1)
defchild_1(self):
self.__logger.info('Child 1')
self.child_2()
defchild_2(self):
self.__logger.info('Child 2')
classParent:
MSG_1='MSG_1'MSG_2='MSG_2'MSG_3='MSG_3'INCREASE_MSG='INCREASE_MSG'DECREASE_MSG='DECREASE_MSG'__logger: NrtLogger__child: Childdef__init__(self):
self.__logger=logger_manager.get_logger(NAME_1)
self.__child=Child()
defa1(self):
self.__logger.warn(self.MSG_1)
self.__child.child_1()
defa2_manual(self):
self.__logger.info(self.MSG_2)
self.__logger.increase_depth()
self.__logger.info(self.INCREASE_MSG)
self.__logger.decrease_depth()
self.__logger.info(self.DECREASE_MSG)
self.__logger.error(self.MSG_1)
self.a1()
defa3_manual(self):
self.__logger.info(self.MSG_2)
self.__logger.increase_depth()
self.__logger.info(self.INCREASE_MSG)
self.__logger.decrease_depth()
self.__logger.info(self.DECREASE_MSG)
self.__logger.error(self.MSG_3)
defa4_manual(self):
self.__logger.info(self.MSG_1)
self.__logger.info(self.INCREASE_MSG, ManualDepthEnum.INCREASE)
self.__logger.info(self.DECREASE_MSG, ManualDepthEnum.DECREASE)
self.__logger.error(self.MSG_2)
fromexamples.demo_classes.demo_classesimportNAME_1, Parentfromnrt_logging.logger_managerimportlogger_managerfromnrt_logging.logger_stream_handlersimport \
ConsoleStreamHandler, LogStyleEnumdeflogging_style(log_style: LogStyleEnum):
sh=ConsoleStreamHandler()
sh.style=log_stylelogger=logger_manager.get_logger(NAME_1)
logger.add_stream_handler(sh)
p=Parent()
p.a1()
deflogging_line_style():
logging_style(LogStyleEnum.LINE)
deflogging_yaml_style():
logging_style(LogStyleEnum.YAML)
logging_yaml_style()

Output

---
date: 2022-10-31 17:59:04.653084log_level: WARNpath: demo_classes.py.Parentmethod: a1line_number: 38message: MSG_1children:
- date: 2022-10-31 17:59:04.655071log_level: INFOpath: demo_classes.py.Childmethod: child_1line_number: 16message: Child 1children:
- date: 2022-10-31 17:59:04.656137log_level: INFOpath: demo_classes.py.Childmethod: child_2line_number: 20message: Child 2

Output in LINE style

- log: 2022-10-31 18:16:54.033735 [WARN] [demo_classes.py.Parent.a1:38] MSG_1children:
- log: 2022-10-31 18:16:54.034660 [INFO] [demo_classes.py.Child.child_1:16] Child 1children:
- log: 2022-10-31 18:16:54.036723 [INFO] [demo_classes.py.Child.child_2:20] Child 2
fromnrt_logging.log_levelimportLogLevelEnumfromnrt_logging.logger_managerimportlogger_managerfromnrt_logging.logger_stream_handlersimport \
ConsoleStreamHandler, LogStyleEnumsh=ConsoleStreamHandler()
sh.log_level=LogLevelEnum.TRACEsh.style=LogStyleEnum.LINElogger=logger_manager.get_logger('NAME_1')
logger.add_stream_handler(sh)
logger.info('main level log')
logger.increase_depth()
logger.info('child 1')
logger.increase_depth()
logger.info('child 1_1')
logger.decrease_depth()
logger.info('child 2')
logger.decrease_depth()
logger.info('continue main level')

Output

- log: 2022-10-31 18:18:34.520544 [INFO] [manual_hierarchy_line_logging_1.py.<module>:13] main level logchildren:
- log: 2022-10-31 18:18:34.522606 [INFO] [manual_hierarchy_line_logging_1.py.<module>:15] child 1children:
- log: 2022-10-31 18:18:34.523784 [INFO] [manual_hierarchy_line_logging_1.py.<module>:17] child 1_1
- log: 2022-10-31 18:18:34.524810 [INFO] [manual_hierarchy_line_logging_1.py.<module>:19] child 2
- log: 2022-10-31 18:18:34.525864 [INFO] [manual_hierarchy_line_logging_1.py.<module>:21] continue main level

Config file

log_manager config file in YAML style.
Configure loggers and stream handlers.

parameters are inherited. Parameters that are deeper in YAML file will be taken.

log_level: WARNdate_format: '%Y-%m-%d %H:%M:%S'loggers:
- name: TEST1style: yamllog_line_template: '[$log_level$] <$date$> $message$'stream_handlers:
- type: consolestyle: line
- type: filefile_path: logs/log_test_1.txtlog_level: DEBUGstyle: linedate_format: '%Y'log_line_template: 'Test1 $date$ $message$'
- name: TEST2style: yamlstream_handlers:
- type: filefile_path: logs/log_test_2.txtlog_level: ERRORdate_format: '%Y'log_yaml_elements:
['log_level', 'date', 'message']
fromnrt_logging.logger_managerimportlogger_managerCONFIG_FILE_PATH='./config/config1.yaml'logger_manager.set_config(file_path=CONFIG_FILE_PATH)

Wiki: https://github.com/etuzon/nrt-logging/wiki

Releases

Packages

Used by

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Universal Dark Mode - works on any site\n(function() {\n var enabled = true;\n \n function applyDarkMode() {\n if (!enabled) return;\n \n // Create style element if it doesn't exist\n var style = document.getElementById('universal-dark-mode-style');\n if (!style) {\n style = document.createElement('style');\n style.id = 'universal-dark-mode-style';\n document.head.appendChild(style);\n }\n \n // Dark mode CSS - inverts colors but preserves images/video\n style.textContent = '\n /* Invert everything except media */\n html {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #1a1a2e !important;\n }\n \n /* Restore images, videos, iframes, canvas */\n img, video, iframe, canvas, svg, picture, [style*=\"background-image\"] {\n filter: invert(1) hue-rotate(180deg) !important;\n }\n \n /* Preserve specific elements that should not be inverted */\n .no-dark-mode, .no-dark-mode *,\n [data-theme=\"light\"], [data-theme=\"light\"],\n .ace_editor, .ace_editor *,\n .CodeMirror, .CodeMirror *,\n .monaco-editor, .monaco-editor *,\n .markdown-body pre, .markdown-body pre *,\n .highlight, .highlight *,\n pre code, pre code * {\n filter: none !important;\n }\n \n /* Fix common UI elements */\n .modal, .popup, .dropdown-menu, .tooltip, .popover {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #2d2d44 !important;\n border-color: #444 !important;\n }\n \n /* Scrollbars */\n ::-webkit-scrollbar { background: #1a1a2e !important; }\n ::-webkit-scrollbar-thumb { background: #444 !important; }\n ::-webkit-scrollbar-thumb:hover { background: #555 !important; }\n \n /* Selection */\n ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ';\n }\n \n function removeDarkMode() {\n var style = document.getElementById('universal-dark-mode-style');\n if (style) style.remove();\n }\n \n // Toggle with Alt+Shift+D\n document.addEventListener('keydown', function(e) {\n if (e.altKey && e.shiftKey && e.key === 'D') {\n e.preventDefault();\n enabled = !enabled;\n if (enabled) {\n applyDarkMode();\n console.log('[Universal Dark Mode] Enabled');\n } else {\n removeDarkMode();\n console.log('[Universal Dark Mode] Disabled');\n }\n }\n });\n \n // Apply on load\n applyDarkMode();\n \n // Re-apply on dynamic content\n var observer = new MutationObserver(function(mutations) {\n if (enabled && !document.getElementById('universal-dark-mode-style')) {\n applyDarkMode();\n }\n });\n observer.observe(document.head, { childList: true });\n \n console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle');\n})();", "Universal Dark Mode"); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })();
Skip to content

Repository files navigation

Hierarchical logging in yaml format.

PyPIPyPI - Python VersionPyPI - LicensePyPI - DownloadsPyPI - DownloadsCoverage StatusGitHub code size in bytesGitHub last commitDeepSource

Hierarchical logging help to group logs that are related to the same code flow.

Log style can be styled in Yaml format or in Line format.

Examples:

Output in YAML style

fromnrt_logging.loggerimportNrtLoggerfromnrt_logging.logger_managerimportlogger_managerfromnrt_logging.logger_stream_handlersimportManualDepthEnumNAME_1='TEST1'NAME_2='TEST2'classChild:
__logger: NrtLoggerdef__init__(self):
self.__logger=logger_manager.get_logger(NAME_1)
defchild_1(self):
self.__logger.info('Child 1')
self.child_2()
defchild_2(self):
self.__logger.info('Child 2')
classParent:
MSG_1='MSG_1'MSG_2='MSG_2'MSG_3='MSG_3'INCREASE_MSG='INCREASE_MSG'DECREASE_MSG='DECREASE_MSG'__logger: NrtLogger__child: Childdef__init__(self):
self.__logger=logger_manager.get_logger(NAME_1)
self.__child=Child()
defa1(self):
self.__logger.warn(self.MSG_1)
self.__child.child_1()
defa2_manual(self):
self.__logger.info(self.MSG_2)
self.__logger.increase_depth()
self.__logger.info(self.INCREASE_MSG)
self.__logger.decrease_depth()
self.__logger.info(self.DECREASE_MSG)
self.__logger.error(self.MSG_1)
self.a1()
defa3_manual(self):
self.__logger.info(self.MSG_2)
self.__logger.increase_depth()
self.__logger.info(self.INCREASE_MSG)
self.__logger.decrease_depth()
self.__logger.info(self.DECREASE_MSG)
self.__logger.error(self.MSG_3)
defa4_manual(self):
self.__logger.info(self.MSG_1)
self.__logger.info(self.INCREASE_MSG, ManualDepthEnum.INCREASE)
self.__logger.info(self.DECREASE_MSG, ManualDepthEnum.DECREASE)
self.__logger.error(self.MSG_2)
fromexamples.demo_classes.demo_classesimportNAME_1, Parentfromnrt_logging.logger_managerimportlogger_managerfromnrt_logging.logger_stream_handlersimport \
ConsoleStreamHandler, LogStyleEnumdeflogging_style(log_style: LogStyleEnum):
sh=ConsoleStreamHandler()
sh.style=log_stylelogger=logger_manager.get_logger(NAME_1)
logger.add_stream_handler(sh)
p=Parent()
p.a1()
deflogging_line_style():
logging_style(LogStyleEnum.LINE)
deflogging_yaml_style():
logging_style(LogStyleEnum.YAML)
logging_yaml_style()

Output

---
date: 2022-10-31 17:59:04.653084log_level: WARNpath: demo_classes.py.Parentmethod: a1line_number: 38message: MSG_1children:
- date: 2022-10-31 17:59:04.655071log_level: INFOpath: demo_classes.py.Childmethod: child_1line_number: 16message: Child 1children:
- date: 2022-10-31 17:59:04.656137log_level: INFOpath: demo_classes.py.Childmethod: child_2line_number: 20message: Child 2

Output in LINE style

- log: 2022-10-31 18:16:54.033735 [WARN] [demo_classes.py.Parent.a1:38] MSG_1children:
- log: 2022-10-31 18:16:54.034660 [INFO] [demo_classes.py.Child.child_1:16] Child 1children:
- log: 2022-10-31 18:16:54.036723 [INFO] [demo_classes.py.Child.child_2:20] Child 2
fromnrt_logging.log_levelimportLogLevelEnumfromnrt_logging.logger_managerimportlogger_managerfromnrt_logging.logger_stream_handlersimport \
ConsoleStreamHandler, LogStyleEnumsh=ConsoleStreamHandler()
sh.log_level=LogLevelEnum.TRACEsh.style=LogStyleEnum.LINElogger=logger_manager.get_logger('NAME_1')
logger.add_stream_handler(sh)
logger.info('main level log')
logger.increase_depth()
logger.info('child 1')
logger.increase_depth()
logger.info('child 1_1')
logger.decrease_depth()
logger.info('child 2')
logger.decrease_depth()
logger.info('continue main level')

Output

- log: 2022-10-31 18:18:34.520544 [INFO] [manual_hierarchy_line_logging_1.py.<module>:13] main level logchildren:
- log: 2022-10-31 18:18:34.522606 [INFO] [manual_hierarchy_line_logging_1.py.<module>:15] child 1children:
- log: 2022-10-31 18:18:34.523784 [INFO] [manual_hierarchy_line_logging_1.py.<module>:17] child 1_1
- log: 2022-10-31 18:18:34.524810 [INFO] [manual_hierarchy_line_logging_1.py.<module>:19] child 2
- log: 2022-10-31 18:18:34.525864 [INFO] [manual_hierarchy_line_logging_1.py.<module>:21] continue main level

Config file

log_manager config file in YAML style.
Configure loggers and stream handlers.

parameters are inherited. Parameters that are deeper in YAML file will be taken.

log_level: WARNdate_format: '%Y-%m-%d %H:%M:%S'loggers:
- name: TEST1style: yamllog_line_template: '[$log_level$] <$date$> $message$'stream_handlers:
- type: consolestyle: line
- type: filefile_path: logs/log_test_1.txtlog_level: DEBUGstyle: linedate_format: '%Y'log_line_template: 'Test1 $date$ $message$'
- name: TEST2style: yamlstream_handlers:
- type: filefile_path: logs/log_test_2.txtlog_level: ERRORdate_format: '%Y'log_yaml_elements:
['log_level', 'date', 'message']
fromnrt_logging.logger_managerimportlogger_managerCONFIG_FILE_PATH='./config/config1.yaml'logger_manager.set_config(file_path=CONFIG_FILE_PATH)

Wiki: https://github.com/etuzon/nrt-logging/wiki

Releases

Packages

Used by

Contributors

Languages