nvflare.security.logging module

is_secure() bool[source]

Checks if logging is set to secure mode.

This is controlled by the system environment variable NVFLARE_SECURE_LOGGING. To set secure mode, set this var to ‘true’ or ‘1’.

Returns:

A boolean indicates whether logging is set in secure mode.

secure_format_exception(e: Exception) str[source]

Formats the specified exception and return a string without sensitive info.

If secure mode is set, only return the type of the exception; If secure mode is not set, return the result of str(e).

Parameters:

e – the exception to be formatted

Returns:

A formatted exception string.

secure_format_traceback() str[source]

Formats the traceback of the current exception and returns a string without sensitive info.

If secure mode is set, only include file names, line numbers and func names. Exception info only includes the type of the exception. If secure mode is not set, return the result of traceback.format_exc().

Returns:

A formatted string

secure_log_traceback(logger: Logger | None = None)[source]

Logs the traceback.

If secure mode is set, the traceback only includes file names, line numbers and func names; and only the type of the exception. If secure mode is not set, the traceback will be logged normally as traceback.print_exc().

Parameters:

logger – if not None, this logger is used to log the traceback detail. If None, the root logger will be used.