Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ DEBUG=true

BEANS_LOGGING_DISABLE_DEFAULT=false
BEANS_LOGGING_CONFIG_PATH="./configs/logger.yml"
BEANS_LOGGING_DIR="./logs"
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,7 @@ DEBUG=true

BEANS_LOGGING_DISABLE_DEFAULT=false
BEANS_LOGGING_CONFIG_PATH="./configs/logger.yml"
BEANS_LOGGING_DIR="./logs"
```

## Configuration
Expand Down
8 changes: 8 additions & 0 deletions beans_logging/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,9 @@ def _check_env(self):
if _is_debug and (self.config.level != "TRACE"):
self.config.level = "DEBUG"

if "BEANS_LOGGING_DIR" in os.environ:
self.config.file.logs_dir = os.getenv("BEANS_LOGGING_DIR")

# if self.config.stream.use_color:
# ## Checking terminal could support xterm colors:
# _TERM = str(os.getenv("TERM")).strip()
Expand All @@ -304,6 +307,11 @@ def _check_config(self):
"level_short:<5", "level.icon:<4"
)

if not os.path.isabs(self.config.file.logs_dir):
self.config.file.logs_dir = os.path.join(
os.getcwd(), self.config.file.logs_dir
)

if "{app_name}" in self.config.file.log_handlers.log_path:
self.config.file.log_handlers.log_path = (
self.config.file.log_handlers.log_path.format(
Expand Down