log
Utilities for managing logging.
init_log(level=logging.DEBUG, comm=comm)
Initialize the sotodlib mapmaking logger with the following extra log levels:
- A
NORMALlog level (25) that is formatted as blue - A
DDEBUGlog level (5)
This also uses LoggerAdapter to add a vairable called extra
that is appended to the end of the the log message.
It can be set with logger.extra['extra'] = ... and defaults to an
empty string.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
level
|
int
|
Logging level (e.g., logging.DEBUG, logging.INFO). Default is logging.DEBUG. |
logging.DEBUG
|
comm
|
Optional[Comm]
|
An MPI communicator. If provided, the logger will include the rank in log messages. Default is None. |
None
|
Returns:
| Type | Description |
|---|---|
LoggerAdapter
|
The logger wrapped in a LoggerAdapter to add the |
Source code in lat_beams/utils/log.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | |
log_lvl(logger, level=None)
Temporarily set a logger (or LoggerAdapter) and its handlers to a different log level. Based on solution from StackOverflow: https://stackoverflow.com/q/78035371/850781
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
logger
|
Logger | LoggerAdapter
|
The logger whose level should be temporarily changed. |
required |
level
|
Optional[int]
|
The temporary log level to use. If None, increases the current effective level by 10. Default is None. |
None
|
Yields:
| Type | Description |
|---|---|
Tuple[int, List[int]]
|
A tuple containing: * The original logger level. * A list of the original levels of all handlers. |
Source code in lat_beams/utils/log.py
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 | |