Utils.logger(日志记录) 模块¶
ppsci.utils.logger
¶
init_logger(name='ppsci', log_file=None, log_level=logging.INFO)
¶
Initialize and get a logger by name.
If the logger has not been initialized, this method will initialize the logger by
adding one or two handlers, otherwise the initialized logger will be directly
returned. During initialization, a StreamHandler will always be added. If log_file
is specified a FileHandler will also be added.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
Logger name. Defaults to "ppsci". |
'ppsci'
|
log_file |
Optional[str]
|
The log filename. If specified, a FileHandler will be added to the logger. Defaults to None. |
None
|
log_level |
int
|
The logger level. Note that only the process of rank 0 is affected, and other processes will set the level to "Error" thus be silent most of the time. Defaults to logging.INFO. |
INFO
|
Source code in ppsci/utils/logger.py
set_log_level(log_level)
¶
Set logger level, only message of level >= log_level
will be printed.
Built-in log level are below:
CRITICAL = 50, FATAL = 50, ERROR = 40, WARNING = 30, WARN = 30, INFO = 20, DEBUG = 10, NOTSET = 0.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
log_level |
int
|
Log level. |
required |
Source code in ppsci/utils/logger.py
info(msg, *args)
¶
message(msg, *args)
¶
debug(msg, *args)
¶
warning(msg, *args)
¶
error(msg, *args)
¶
scalar(metric_dict, step, vdl_writer=None, wandb_writer=None, tbd_writer=None)
¶
This function will add scalar data to VisualDL or WandB for plotting curve(s).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
metric_dict |
Dict[str, float]
|
Metrics dict with metric name and value. |
required |
step |
int
|
The step of the metric. |
required |
vdl_writer |
Optional[LogWriter]
|
VisualDL writer to record metrics. Defaults to None. |
None
|
wandb_writer |
Optional[run]
|
Run object of WandB to record metrics. Defaults to None. |
None
|
tbd_writer |
Optional[SummaryWriter]
|
Run object of WandB to record metrics. Defaults to None. |
None
|