sinks
DefaultSinks
Bases: LoguruSinkBase
Return initialized defaults for Loguru sink classes.
Access initialized sinks as class parameters. For example, to get an STDOUT logger,
initialized with the default LoguruSinkStdOut settings: DefaultSinks().stdout
To get a list of initialized default sinks (an app.log, err.log, and STDOUT logger), choose
from .color (for loggers initialized with colorize; excludes file loggers), or .nocolor (no colorize initialized):
DefaultSinks().stdout.color
Source code in src/red_utils/ext/loguru_utils/sinks.py
color: list[dict]
property
List of initialized Loguru loggers.
Returns
(list[dict]): List of Loguru sink dicts with `colorize=True`.
no_color: list[dict]
property
List of initialized Loguru loggers.
Returns
(list[dict]): List of Loguru sink dicts with `colorize=False`.
LoguruSinkAppFile
dataclass
Bases: LoguruSinkFileBase, DictMixin
Sink class for app.log file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sink |
(str, TextIO)
|
the Loguru sink definition |
field(default=f'{LOG_DIR}/app.log')
|
colorize |
bool
|
If |
field(default=True)
|
retention |
str | int
|
Amount of time to retain log files |
field(default=3)
|
rotation |
str
|
Size limit when a log file will be rotated |
field(default='5 MB')
|
format |
str
|
A formatted string for log messages |
field(default=default_fmt)
|
level |
str
|
Level of logs to log to file, i.e. |
field(default='DEBUG')
|
enqueue |
bool
|
Set to |
field(default=True)
|
Source code in src/red_utils/ext/loguru_utils/sinks.py
LoguruSinkBase
dataclass
Bases: DictMixin
Base Loguru sink class.
Define common options for children to inherit from.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sink |
str | TextIO
|
A Loguru sink. Can be a string (i.e. "app.log" for a file at ./app.log) or a Python callable (i.e. sys.stdout). Loguru Docs: sinks |
field(default=stdout)
|
format |
str
|
A string describing the format for the Loguru logger. Loguru Docs: time formatting. Loguru Docs: color markup formatting. |
field(default=default_fmt)
|
level |
str
|
A severity level string for the logger. Controls which messages will be outputted. Value will be forced uppercase. Loguru Docs: Severity levels |
field(default='INFO')
|
colorize |
bool
|
Control whether logger outputs are colorized. |
field(default=False)
|
Source code in src/red_utils/ext/loguru_utils/sinks.py
LoguruSinkDefault
dataclass
Bases: LoguruSinkBase
Default Loguru sink. Defaults to colorized, formatted stdout, level=INFO.
Use this class as a starting point to create customized Loguru sinks. Create a new class by inheriting from this one:
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sink |
str | TextIO
|
A Loguru sink. Can be a string (i.e. "app.log" for a file at ./app.log) or a Python callable (i.e. sys.stdout). Loguru Docs: sinks |
field(default=stdout)
|
format |
str
|
A string describing the format for the Loguru logger. Loguru Docs: time formatting. Loguru Docs: color markup formatting. |
field(default=default_fmt)
|
level |
str
|
A severity level string for the logger. Controls which messages will be outputted. Value will be forced uppercase. Loguru Docs: Severity levels |
field(default='INFO')
|
colorize |
bool
|
Control whether logger outputs are colorized. |
field(default=False)
|
Source code in src/red_utils/ext/loguru_utils/sinks.py
LoguruSinkErrFile
dataclass
Bases: LoguruSinkFileBase
Sink class for error.log file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sink |
(str, TextIO)
|
the Loguru sink definition |
field(default=f'{LOG_DIR}/error.log')
|
colorize |
bool
|
If |
field(default=True)
|
retention |
str | int
|
Amount of time to retain log files |
field(default=3)
|
rotation |
str
|
Size limit when a log file will be rotated |
field(default='5 MB')
|
format |
str
|
A formatted string for log messages |
field(default=default_fmt)
|
level |
str
|
Level of logs to log to file, i.e. |
field(default='ERROR')
|
enqueue |
bool
|
Set to |
field(default=True)
|
Source code in src/red_utils/ext/loguru_utils/sinks.py
LoguruSinkFileBase
dataclass
Bases: DictMixin
Base class for file sinks.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sink |
(str, TextIO)
|
the Loguru sink definition |
field(default=f'{LOG_DIR}/app.log')
|
colorize |
bool
|
If |
field(default=True)
|
retention |
str | int
|
Amount of time to retain log files |
field(default=3)
|
rotation |
str
|
Size limit when a log file will be rotated |
field(default='5 MB')
|
format |
str
|
A formatted string for log messages |
field(default=default_fmt)
|
level |
str
|
Level of logs to log to file, i.e. |
field(default='DEBUG')
|
enqueue |
bool
|
Set to |
field(default=True)
|
Source code in src/red_utils/ext/loguru_utils/sinks.py
LoguruSinkFileDefault
dataclass
Bases: LoguruSinkFileBase
Default Loguru file sink. Defaults to file app.log, level=DEBUG.
Use this class as a starting point to create customized Loguru file sinks. Create a new class by inheriting from this one:
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sink |
(str, TextIO)
|
the Loguru sink definition |
field(default=f'{LOG_DIR}/app.log')
|
colorize |
bool
|
If |
field(default=True)
|
retention |
str | int
|
Amount of time to retain log files |
field(default=3)
|
rotation |
str
|
Size limit when a log file will be rotated |
field(default='5 MB')
|
format |
str
|
A formatted string for log messages |
field(default=default_fmt)
|
level |
str
|
Level of logs to log to file, i.e. |
field(default='DEBUG')
|
enqueue |
bool
|
Set to |
field(default=True)
|
Source code in src/red_utils/ext/loguru_utils/sinks.py
LoguruSinkStdErr
dataclass
Bases: LoguruSinkBase
Console STDERR sink.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sink |
(str, TextIO)
|
the Loguru sink definition |
field(default=stderr)
|
format |
str
|
A formatted string for log messages |
field(default=default_color_fmt)
|
colorize |
bool
|
If |
field(default=True)
|
Source code in src/red_utils/ext/loguru_utils/sinks.py
LoguruSinkStdOut
dataclass
Bases: LoguruSinkBase, DictMixin
Console STDOUT sink.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
format |
str
|
A formatted string for log messages |
field(default=default_color_fmt)
|
colorize |
bool
|
If |
field(default=True)
|
Source code in src/red_utils/ext/loguru_utils/sinks.py
LoguruSinkTraceFile
dataclass
Bases: LoguruSinkFileBase
Sink class for trace.log file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sink |
(str, TextIO)
|
the Loguru sink definition |
field(default=f'{LOG_DIR}/trace.log')
|
colorize |
bool
|
If |
field(default=True)
|
retention |
str | int
|
Amount of time to retain log files |
field(default=3)
|
rotation |
str
|
Size limit when a log file will be rotated |
field(default='5 MB')
|
format |
str
|
A formatted string for log messages |
field(default=default_fmt)
|
level |
str
|
Level of logs to log to file, i.e. |
field(default='TRACE')
|
enqueue |
bool
|
Set to |
field(default=True)
|