neclib.core.inform#

Aliases#

deprecated

Decorator to mark a function as deprecated.

deprecated_namespace

None

disabled

A decorator to disable a function or method.

get_logger

Get logger instance which prints operation logs to console.

deprecated(__callable=None, *, version_since=None, version_removed=None, reason=None, replacement=None)[source]#

Decorator to mark a function as deprecated.

Parameters:
  • __callable (Optional[Callable[[...], Any]]) – A callable object to be decorated.

  • version_since (Optional[str]) – The version since which the function is deprecated.

  • version_removed (Optional[str]) – The version in which the function will be removed.

  • reason (Optional[str]) – The reason for deprecation.

  • replacement (Optional[str]) – The replacement for the deprecated function.

Returns:

A callable object with deprecation warning.

Return type:

deprecated

Examples

>>> @deprecated
... def foo():
...     pass
>>> foo()
DeprecationWarning: The use of `foo` is deprecated. There is no replacement.
deprecated_namespace(*args, **kwargs)[source]#
get_logger(name=None, min_level=None, throttle_duration_sec=1.0)[source]#

Get logger instance which prints operation logs to console.

Parameters:
  • name (Optional[str]) – Name of the logger. Calling this function with same name returns the same logger instance.

  • min_level (Optional[int]) – Lower bound of severity level to be displayed on terminal. To suppress less severe messages, set higher value. No matter this value, the log file contains all messages severer than logging.INFO (level=20).

  • throttle_duration_sec (Union[int, float]) – Duration in seconds to throttle messages. If the same message is logged within this duration, the message is not displayed on terminal.

Return type:

Logger

Examples

>>> logger = neclib.interfaces.getLogger("OTF_observation", "path/to/log.txt")
>>> logger.debug("Inform something only needed on diagnosing some problem.")
>>> logger.info("Inform something EXPECTED has happened.")
>>> logger.warning("Inform something user should care has happened.")
>>> logger.error(f"Notify some {functionality} cannot be completed due to error.")
>>> logger.critical(
...     "Notify the %s cannot continue operation due to %s", "program", "some error"
... )
>>> logger.obslog("Observation finished", indent_level=1)
disabled(func)[source]#

A decorator to disable a function or method.

This may be used to make a tentative implementation not accessible.

Submodules#

neclib.core.inform.console_logger

neclib.core.inform.deprecation

Inform deprecation.

neclib.core.inform.disable