@@ -47,6 +47,7 @@ class LoggerLoader:
4747 _load_env_vars() : Load 'BEANS_LOGGING_CONFIG_PATH' environment variable for logger config file path.
4848 _load_config_file() : Load logger config from file.
4949 _check_env() : Check environment variables for logger config.
50+ _check_config() : Check logger config to update some options before loading handlers.
5051 _add_stream_std_handler() : Add std stream handler to logger.
5152 _add_file_log_handler() : Add log file handler to logger.
5253 _add_file_err_handler() : Add error log file handler to logger.
@@ -101,6 +102,7 @@ def load(self) -> Logger:
101102 self .remove_handler ()
102103
103104 self ._check_env ()
105+ self ._check_config ()
104106
105107 if self .config .stream .std_handler .enabled :
106108 self ._add_stream_std_handler ()
@@ -286,6 +288,15 @@ def _check_env(self):
286288 if _is_debug and (self .config .level != "TRACE" ):
287289 self .config .level = "DEBUG"
288290
291+ # if self.config.stream.use_color:
292+ # ## Checking terminal could support xterm colors:
293+ # _TERM = str(os.getenv("TERM")).strip()
294+ # if not "xterm" in _TERM:
295+ # self.config.stream.use_color = False
296+
297+ def _check_config (self ):
298+ """Check logger config to update some options before loading handlers."""
299+
289300 if self .config .level == "TRACE" :
290301 self .config .use_diagnose = True
291302
@@ -294,11 +305,33 @@ def _check_env(self):
294305 "level_short:<5" , "level.icon:<4"
295306 )
296307
297- # if self.config.stream.use_color:
298- # ## Checking terminal could support xterm colors:
299- # _TERM = str(os.getenv("TERM")).strip()
300- # if not "xterm" in _TERM:
301- # self.config.stream.use_color = False
308+ if "{app_name}" in self .config .file .log_handlers .log_path :
309+ self .config .file .log_handlers .log_path = (
310+ self .config .file .log_handlers .log_path .format (
311+ app_name = self .config .app_name
312+ )
313+ )
314+
315+ if "{app_name}" in self .config .file .log_handlers .err_path :
316+ self .config .file .log_handlers .err_path = (
317+ self .config .file .log_handlers .err_path .format (
318+ app_name = self .config .app_name
319+ )
320+ )
321+
322+ if "{app_name}" in self .config .file .json_handlers .log_path :
323+ self .config .file .json_handlers .log_path = (
324+ self .config .file .json_handlers .log_path .format (
325+ app_name = self .config .app_name
326+ )
327+ )
328+
329+ if "{app_name}" in self .config .file .json_handlers .err_path :
330+ self .config .file .json_handlers .err_path = (
331+ self .config .file .json_handlers .err_path .format (
332+ app_name = self .config .app_name
333+ )
334+ )
302335
303336 def _add_stream_std_handler (self ) -> int :
304337 """Add std stream handler to logger.
0 commit comments