ska_sdp_piper.piper.utils.log_util module
- class ska_sdp_piper.piper.utils.log_util.LogUtil[source]
Bases:
objectA class to setup logging configuration in the context of piper based pipelines.
This also stores some global settings related to the logging, which might be useful for the pipelines or runners.
-
log_file:
str|None= None Stores the file path to which the logs will be written. Piper will set this up on behalf of the user.
- classmethod configure(log_file=None, verbose=False, disable_console=False)[source]
Setup logging config as per the SKA Logging Format. Additionally, this can setup logging to a file, and can disable logging to stdout.
Every call to this function will override the existing global logging config. Ideally in the appplication's lifecycle, this function should be called once, as early as possible.
- Parameters:
log_file (
str|None, default:None) -- Path to log file. If None or if value is "falsy", logs are not written to a file.verbose (
bool, default:False) -- If True, set the log level to DEBUG, else set to INFO.disable_console (
bool, default:False) -- By default, the ska_ser_logging logger logs to the sys.stdout stream. This can be disabled by setting disable_console value to True.
-
log_file:
- class ska_sdp_piper.piper.utils.log_util.LogPlugin(log_file=None, verbose=False, disable_console=False)[source]
Bases:
WorkerPluginDask worker plugin that configures logging on worker startup.
This accepts same parameters as the
LogUtil.configure()function. Refer to that function for details.Example
>>> plugin = LogPlugin(verbose=LogUtil.verbose) >>> client.register_worker_plugin(plugin)
- idempotent = True
- ska_sdp_piper.piper.utils.log_util.delayed_log(logger, formated_log_msg, **kwargs)
Log a formatted message in a Dask-delayed task. This ensures that dask delayed objects inside kwargs dictionary, whose results are needed for logging a message, are not computed eagerly.
- Parameters:
Example
>>> # Assuming root logger can stream to stdout >>> logger = logging.getLogger() >>> task = delayed_log( ... logger.info, ... "{var_1} and {var_2}", ... var_1=10, ... var_2=dask.delayed(list)([1, 2, 3]) ... ) >>> task.compute() "10 and [1, 2, 3]"