|
Rotary Logger
1.0.2
The middleware rotary logger
|

Public Member Functions | |
| None | __init__ (self, CONST.ErrorMode output_error=CONST.ErrorMode.WARN_NO_PIPE) |
| run (self) | |
Data Fields | |
| CONST.ErrorMode | output_error = output_error |
| args = self._parse_args() | |
| RotaryLogger | rotary_logger |
Protected Member Functions | |
| _parse_args (self) | |
| None | _handle_interrupts_if_required (self) |
| None | _pipe_check (self) |
Small helper used when running the package as a CLI entrypoint. This convenience class wraps creation of a `RotaryLogger` when the package is executed as a program (it mirrors behaviour of the standalone `rotary` command). It also provides small runtime configuration points such as whether to override existing logs, to ignore keyboard interrupts, and which broken-pipe handling policy to use.
Definition at line 47 of file entrypoint.py.
| None rotary_logger.entrypoint.Tee.__init__ | ( | self, | |
| CONST.ErrorMode | output_error = CONST.ErrorMode.WARN_NO_PIPE ) |
Initialise the entrypoint helper and configure the logger.
Parses CLI arguments, installs the SIGINT handler when requested,
and creates the underlying RotaryLogger instance.
Keyword Arguments:
output_error (CONST.ErrorMode): Policy for handling broken-pipe or stdout errors. Default: CONST.ErrorMode.WARN_NO_PIPE
Definition at line 58 of file entrypoint.py.
|
protected |
Ignore SIGINT (KeyboardInterrupt) when configured to do so. Installs a SIG_IGN handler for SIGINT when the --ignore-interrupts flag was passed on the command line. This is a no-op when interrupts should be processed normally.
Definition at line 187 of file entrypoint.py.
|
protected |
Parse command-line arguments for the tee entrypoint.
Returns:
The populated argparse.Namespace with the parsed arguments.
Definition at line 108 of file entrypoint.py.
|
protected |
Apply the configured broken-pipe error policy. Writes a warning to stderr or exits the process depending on the value of self.output_error and whether stdout is currently a pipe.
Definition at line 197 of file entrypoint.py.
| rotary_logger.entrypoint.Tee.run | ( | self | ) |
Start logging and run the main stdin-to-stdout forwarding loop. Behaves like UNIX tee: reads lines from stdin, prints them to stdout (which is wrapped by RotaryLogger), and mirrors everything to the configured log folder. Handles BrokenPipeError per the configured error policy and KeyboardInterrupt when interrupts are not suppressed.
Definition at line 214 of file entrypoint.py.
| rotary_logger.entrypoint.Tee.args = self._parse_args() |
Definition at line 71 of file entrypoint.py.
| CONST.ErrorMode rotary_logger.entrypoint.Tee.output_error = output_error |
Definition at line 70 of file entrypoint.py.
| RotaryLogger rotary_logger.entrypoint.Tee.rotary_logger |
Definition at line 90 of file entrypoint.py.