N2PLog#
- class NaxToPy.Core.Errors.N2PLog.N2PLog[source]#
Bases:
ABCClass prepared for the control of the program.
It uses the module logging to register the main instructions and data of the NaxToPy Package. It can’t be instanced.
- LevelList#
- classmethod activate_log() None[source]#
Method that activates the .log
Turning the file back on brings its level into the threshold again. See deactivate_log().
- classmethod deactivate_log() None[source]#
Method that deactivates the .log
Turning the file off moves the visibility threshold as much as a level change does, because while it is off nothing reaches the file whatever its level says. The threshold then rests on the console alone, and whatever depends on it is told.
- classmethod get_console_level() Literal['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'][source]#
Method that returns the level currently set for the console.
Same remark as get_file_level(): the class attribute clv holds the level the class was built with and is not kept up to date by set_console_level(), so this method is the only reliable way of reading the current one.
The name of the setter parameter is also clv, which is what makes the confusion easy: it is a local name that has nothing to do with the class attribute of the same name.
Unlike the file, the console has no on/off switch: this level alone decides what is printed.
- classmethod get_directory() str[source]#
Method that returns the folder where the .log file is being saved
- classmethod get_file_level() Literal['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'][source]#
Method that returns the level currently set for the .log file.
It reads the level this class holds for the file handler, which set_file_level() keeps in step with the handler itself. The class attribute flv is a different thing: it holds the level the class was built with and is NOT kept up to date, so this method is the only reliable way of reading the current one.
The level says nothing about whether the file is being written at all: deactivate_log() turns the file off without touching the level, and while it is off nothing reaches the file regardless of what this returns. See get_visibility_threshold() for the two combined.
- classmethod get_visibility_threshold() int[source]#
Method that returns the lowest level at which a record is still seen somewhere.
WHY THE LOWEST AND NOT THE HIGHEST. A record is filtered twice: first by the logger, which is set to DEBUG and therefore lets everything through, and then by each handler on its own. One handler accepting it is enough for the record to be seen, so what decides whether a record is seen ANYWHERE is the lowest of the levels in play, not the highest. With the file at INFO and the console at WARNING, an INFO record misses the console and still reaches the .log.
WHY THE TWO CHANNELS ARE NOT TREATED ALIKE. The console is always live, so its level always counts. The file has an on/off switch that is independent of its level -deactivate_log() and activate_log()-, and while it is off nothing reaches the file, not even a CRITICAL record. Its level then says nothing about visibility and must not drag the result down: reading it anyway is what would leave a deactivated .log sitting at INFO reporting a threshold of INFO while nobody can see a thing.
WHAT IT IS FOR. Anything logged below this threshold is discarded by both handlers of this register, so producing it is wasted work. It is meant for callers that can choose HOW MUCH to produce and want to stop short of producing what nobody will read.
IT RETURNS AN INTEGER and not a name, unlike get_file_level() and get_console_level(), because what callers do with it is compare it against logging.ERROR, logging.WARNING and the like. Handing back a name would only force them to translate it back.
- Returns:
one of the logging module level values, always between DEBUG and CRITICAL.
- Return type:
int
- classmethod is_input_checking() bool[source]#
Return whether the input checking is currently enabled.
- Returns:
True if input files are validated while being read.
- Return type:
bool
- classmethod set_console_level(clv: Literal['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL']) None[source]#
Method to set a different level for console register. The default level is “WARNING”. Only The level register and higher will be printed in the console. The possible levels are:
“DEBUG”, “INFO”, “WARNING”, “ERROR”, “CRITICAL”.
- classmethod set_directory(value: str) None[source]#
Method that sets the folder where the .log file must be saved
- Parameters:
value – str -> Path to the folder where the .log must be saved.
- classmethod set_file_level(flv: Literal['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL']) None[source]#
Method to set a different level for the file .log of the register. The default level is “INFO”. Only The level register and higher will be printed in the .log file. Higher levels could make more difficult to track errors. The possible levels are:
“DEBUG”, “INFO”, “WARNING”, “ERROR”, “CRITICAL”.
- classmethod set_file_name(value: str) None[source]#
Method that sets the name of the file of the .log
- Parameters:
value – str -> Name of the .log file
- classmethod set_input_checking(enabled: bool = True) None[source]#
Enable or disable the input checking when reading input files.
- Parameters:
enabled (bool, optional) – If True, input files are validated while being read. Default is True. Input checking is disabled when the class is first loaded.
- LevelList = ['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL']#
- clv = 'WARNING'#
- flv = 'INFO'#