Rotary Logger  1.0.2
The middleware rotary logger
Loading...
Searching...
No Matches
rotary_logger.entrypoint.Tee Class Reference
Collaboration diagram for rotary_logger.entrypoint.Tee:
Collaboration graph

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)
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ __init__()

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.

Member Function Documentation

◆ _handle_interrupts_if_required()

None rotary_logger.entrypoint.Tee._handle_interrupts_if_required ( self)
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.

◆ _parse_args()

rotary_logger.entrypoint.Tee._parse_args ( self)
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.

◆ _pipe_check()

None rotary_logger.entrypoint.Tee._pipe_check ( self)
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.

◆ run()

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.

Field Documentation

◆ args

rotary_logger.entrypoint.Tee.args = self._parse_args()

Definition at line 71 of file entrypoint.py.

◆ output_error

CONST.ErrorMode rotary_logger.entrypoint.Tee.output_error = output_error

Definition at line 70 of file entrypoint.py.

◆ rotary_logger

RotaryLogger rotary_logger.entrypoint.Tee.rotary_logger
Initial value:
= RotaryLogger(
log_to_file=False,
override=not self.args.append,
merge_streams=self.args.merge,
merge_stdin=self.args.merge_stdin,
capture_stdin=self.args.capture_stdin,
capture_stdout=self.args.capture_stdout,
capture_stderr=self.args.capture_stderr,
prefix_in_stream=self.args.prefix_in,
prefix_out_stream=self.args.prefix_out,
prefix_err_stream=self.args.prefix_err,
log_function_calls_stdin=log_function_calls_stdin,
log_function_calls_stdout=log_function_calls_stdout,
log_function_calls_stderr=log_function_calls_stderr,
program_log=program_log,
program_debug_log=program_debug_log,
)

Definition at line 90 of file entrypoint.py.


The documentation for this class was generated from the following file: