logging
RichFileLogger(log_file, append=False, color=True)
¶
Singleton-per-path, ref-counted, thread-safe file logger.
• Any number of calls to RichFileLogger(path)
yield the same object.
• A per-instance lock guarantees that the underlying file is opened only
once, even when many threads construct the logger concurrently.
• A reference counter tracks how many parts of the program are using the
logger; the FD is closed only when the counter reaches zero.
• All writes are serialised with a dedicated write-lock.
Source code in langroid/utils/logging.py
log(message)
¶
Thread-safe write to the log file.
Source code in langroid/utils/logging.py
close()
¶
Decrease ref-count; close FD only when last user is done.
Source code in langroid/utils/logging.py
setup_logger(name, level=logging.INFO, terminal=False)
¶
Set up a logger of module name
at a desired level.
Args:
name: module name
level: desired logging level
Returns:
logger
Source code in langroid/utils/logging.py
setup_loggers_for_package(package_name, level)
¶
Set up loggers for all modules in a package. This ensures that log-levels of modules outside the package are not affected. Args: package_name: main package name level: desired logging level Returns: