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
4 changes: 2 additions & 2 deletions examples/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@

from logurich import global_context_configure, init_logger, logger

logger.info("This is a basic log message")


def create_rich_table():
table = Table(title="Sample Table")
Expand All @@ -17,6 +15,8 @@ def create_rich_table():


if __name__ == "__main__":
init_logger("INFO")
logger.info("This is a basic log message")
logger.info("Example message")
logger.rich("INFO", "OK")
logger.rich("INFO", {"fake": "test"})
Expand Down
2 changes: 0 additions & 2 deletions src/logurich/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
propagate_loguru_to_std_logger,
)

init_logger("INFO")

__all__ = [
"init_logger",
"logger",
Expand Down
9 changes: 8 additions & 1 deletion src/logurich/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -496,13 +496,16 @@ def init_logger(
diagnose: bool = False,
enqueue: bool = True,
highlight: bool = False,
enable_all: bool = True,
rotation: Optional[Union[str, int]] = "12:00",
retention: Optional[Union[str, int]] = "10 days",
) -> Optional[str]:
"""Initialize and configure the logger with rich formatting and customized handlers.

This function sets up a logging system using Loguru with optional Rich integration.
It configures console output and optionally file-based logging with rotation.
It configures console output and optionally file-based logging with rotation. Call
it early in your application's startup before any logging, since LoguRich does not
auto-initialize handlers.

Args:
log_level: The minimum logging level to display (e.g. "DEBUG", "INFO", "WARNING").
Expand All @@ -525,6 +528,8 @@ def init_logger(
enqueue (bool, optional): Whether to use a queue for thread-safe logging.
Defaults to True.
highlight (bool, optional): Whether to highlight log messages. Defaults to False.
enable_all (bool, optional): Whether to enable logging for all modules.
Defaults to True.
rotation (str or int or None, optional): When to rotate log files. Can be a time string
(e.g. "12:00", "1 week"), size (e.g. "500 MB"), or None to disable rotation.
Defaults to "12:00".
Expand All @@ -540,6 +545,8 @@ def init_logger(
>>> logger.info("Application started")
>>> logger.debug("Debug information") # Won't be displayed with INFO level
"""
if enable_all:
logger.enable("")
if rich_handler is False:
env_rich_handler = parse_bool_env("LOGURU_RICH")
if env_rich_handler is not None:
Expand Down