-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Logging
Edward Chen edited this page May 7, 2021
·
1 revision
A basic example:
// include this header for logging facilities
#include "core/common/logging/logging.h"
void LogAValue(int value) {
// logs a message with INFO severity using the default logger
LOGS_DEFAULT(INFO) << "FYI, the value is " << value;
}
LOG macros are for general logging, which will be output at the appropriate log level (onnxruntime::logging::Severity).
VLOG macros log at the highest verbosity level (VERBOSE) and are only enabled for debug builds. Within VLOG, there are more verbosity levels (int, higher is more verbose). To see VLOG messages, in addition to setting the log level (onnxruntime::logging::Severity) to VERBOSE, you'll also have to set the max vlog level (int).
So VLOG is intended for debugging output. LOG is for messages at other verbosity levels.
See these files for more details:
- Prefer to log over writing directly to stdout or stderr.
- When there’s a non-recoverable error, we simply return a non-OK status object or throw an exception that gets caught at the topmost layer. You can use ERROR in such situations to log the failure condition.
- WARNING is used for cases where we can recover, but would like the user to fix their input/model. Like remove an unused initializer from the model.
- Given the above, FATAL is not of much use.
- VERBOSE vs. VLOG is very subjective. If you want to log a lot of details to debug issues, use VLOG, otherwise VERBOSE should do fine.
- INFO is just FYI about some important milestones – like completed loading a model, completed initialization, etc.
- The LOG_USER macro was for logging any user specific stuff. We don’t have much use for it.
- If you’ve not created a specific logger instance for your application, just use LOGS_DEFAULT.
Please use the learning roadmap on the home wiki page for building general understanding of ORT.