Coverage for opt/mealie/lib/python3.12/site-packages/mealie/core/root_logger.py: 88%
18 statements
« prev ^ index » next coverage.py v7.10.6, created at 2025-11-25 17:29 +0000
« prev ^ index » next coverage.py v7.10.6, created at 2025-11-25 17:29 +0000
1import logging 1a
3from .config import get_app_dirs, get_logging_settings 1a
4from .logger.config import configured_logger 1a
6__root_logger: None | logging.Logger = None 1a
9def get_logger(module=None) -> logging.Logger: 1a
10 """
11 Get a logger instance for a module, in most cases module should not be
12 provided. Simply using the root logger is sufficient.
14 Cases where you would want to use a module specific logger might be a background
15 task or a long running process where you want to easily identify the source of
16 those messages
17 """
18 global __root_logger
20 if __root_logger is None: 2a b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + , - . / : ; = ? @ [ ] ^ _ ` { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbrbsbtbubvbwbxbybzbAbBbCbDbEbFb
21 app_logging_settings = get_logging_settings() 1a
23 mode = "development" 1a
25 if app_logging_settings.TESTING: 25 ↛ 26line 25 didn't jump to line 26 because the condition on line 25 was never true1a
26 mode = "testing"
27 elif app_logging_settings.PRODUCTION: 27 ↛ 30line 27 didn't jump to line 30 because the condition on line 27 was always true1a
28 mode = "production" 1a
30 dirs = get_app_dirs() 1a
32 substitutions = { 1a
33 "DATA_DIR": dirs.DATA_DIR.as_posix(),
34 "LOG_LEVEL": app_logging_settings.LOG_LEVEL.upper(),
35 }
37 __root_logger = configured_logger( 1a
38 mode=mode,
39 config_override=app_logging_settings.LOG_CONFIG_OVERRIDE,
40 substitutions=substitutions,
41 )
43 if module is None: 2a b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + , - . / : ; = ? @ [ ] ^ _ ` { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbrbsbtbubvbwbxbybzbAbBbCbDbEbFb
44 return __root_logger 2a b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9 ! # $ % ' ( ) * + , - . / : ; = ? @ [ ] ^ _ ` { | } ~ abbbcbdbebfbgbhbibjbkblbmbnbobpbqbrbsbtbubvbwbxbybzbAbBbCbDbEbFb
46 return __root_logger.getChild(module) 1a