|
CLog 0.1.0
logging as simple as putting on a shoe
|
Classes | |
| class | Colours |
Functions | |
| str | loglevel_as_str (Union[LogLevel, int] level) |
| str | log_as_col (Union[int, LogLevel] level) |
| str | gen_log_header (Union[LogLevel, int, str] _type) |
| str | wrap (str value, *int width=120, int tb_size=4) |
Variables | |
| string | __LOG_TMPL = "[{DATE}] [{0}] {TYPE} " |
| log message constant format template More... | |
| string | __TIMESTAMP_FMT = "%Y-%m-%dT%H:%M:%S%z" |
| string time format (ISO: 8601, long-form) More... | |
| str clog.utils.printfmt.gen_log_header | ( | Union[LogLevel, int, str] | _type | ) |
Generate a header string for use of standardising log outputs.
The header is defined using the following standard header:
```plaintext
"[YYYY-MM-DDTHH:MM:SS+OFFSET] [{CALLER}] <LogLevel> {0}"
```
The first column defines the Date-Time following the ISO 8601 (long)
standard timestamp format, whereby `T` is the separator between Date
and Time. The `+OFFSET` is the number of hours ahead/behind UTC, the
currently timezone set by the PC. This is achieved using the following
string to time format:
`%Y-%m-%dT%H:%M:%S%z`.
The second column is reversed during the return value of the string.
This column is used to allow for a stacktrace to be attached to the
log message.
The third column defines the level of the log message. This will be
five blank space characters if a level is passed outside of the
defined scope of logging levels.
The fourth column is reserved during the return value of the string.
It represents the body of the message to be logged.
`@Params`: _type - `LogLevel | int | str`
`@Return`: Formattable string - `str`
| str clog.utils.printfmt.log_as_col | ( | Union[int, LogLevel] | level | ) |
Convert an integer or enum value into an associated ANSI escape code terminal colour sequence. Depending on log level severity, an associated colour is returned to give STDOUT text a distinct separation of colour from regular STDOUT text. `@Params`: level - `LogLevel | int` `@Return`: Enum of `Colours`
| str clog.utils.printfmt.loglevel_as_str | ( | Union[LogLevel, int] | level | ) |
Convert an integer or enum value into its appropriate enum attribute name. `@Params`: level - `LogLevel | int` `Returns`: LogLevel enum literal attribute name - `str`
| str clog.utils.printfmt.wrap | ( | str | value, |
| *int | width = 120, |
||
| int | tb_size = 4 |
||
| ) |
Return a hard-wrapped string defined by a fixed width. Wrapped text is separated by a `\\n` character and a fixed width of 120 characters. Each wrap is appended with a tab size of 4 characters at the start of each line-wrap. `@Params`: value - `str`, width = 120 - `int`, tb_size = 4 - `int` `@Return`: `str`
|
private |
log message constant format template
|
private |
string time format (ISO: 8601, long-form)