spec2vec.logging_functions module

Spec2Vec logger.

Spec2Vec functions and method report unexpected or undesired behavior as logging WARNING, and additional information as INFO. The default logging level is set to WARNING. The logger is an adaptation of the matchms logger.

If you want to output additional logging messages, you can lower the logging level to INFO using set_spec2vec_logger_level:

from spec2vec import set_spec2vec_logger_level

set_spec2vec_logger_level("INFO")

This can also be combined with setting the matchms logger which occurs separately by using set_matchms_logger_level:

from matchms import set_matchms_logger_level
from spec2vec import set_spec2vec_logger_level

set_matchms_logger_level("INFO")
set_spec2vec_logger_level("INFO")

If you want to suppress logging warnings, you can also raise the logging level to ERROR by:

set_spec2vec_logger_level("ERROR")

To write logging entries to a local file, you can do the following:

from spec2vec.logging_functions import add_logging_to_file

add_logging_to_file("sample.log", loglevel="INFO")

If you want to write the logging messages to a local file while silencing the stream of such messages, you can do the following:

from spec2vec.logging_functions import add_logging_to_file

add_logging_to_file("sample.log", loglevel="INFO",
                    remove_stream_handlers=True)
spec2vec.logging_functions.add_logging_to_file(filename: str, loglevel: str = 'INFO', remove_stream_handlers: bool = False, logger_name='spec2vec')[source]

Add logging to file.

Current implementation does not change the initial logging stream, but simply adds a FileHandler to write logging entries to a file.

Parameters
  • filename – Name of file for write logging output.

  • loglevels – Can be ‘DEBUG’, ‘INFO’, ‘WARNING’, ‘ERROR’, ‘CRITICAL’.

  • remove_stream_handlers – Set to True if only logging to file is desired.

  • logger_name – Default is “spec2vec”. Change if logger name should be different.

spec2vec.logging_functions.reset_spec2vec_logger(logger_name='spec2vec')[source]

Reset spec2vec logger to initial state.

This will remove all logging Handlers and initialize a new spec2vec logger. Use this function to reset previous changes made to the default spec2vec logger.

Parameters

logger_name – Default is “spec2vec”. Change if logger name should be different.

spec2vec.logging_functions.set_spec2vec_logger_level(loglevel: str, logger_name='spec2vec')[source]

Update logging level to given loglevel.

Parameters
  • loglevels – Can be ‘DEBUG’, ‘INFO’, ‘WARNING’, ‘ERROR’, ‘CRITICAL’.

  • logger_name – Default is “spec2vec”. Change if logger name should be different.