xref: /cloud-hypervisor/docs/logging.md (revision 9988379f6b15ead0d780995eccbaa05999278f04)
18824da27SRob Bradford# Logging
28824da27SRob Bradford
38824da27SRob BradfordThe target audience of this document is both:
48824da27SRob Bradford
5*9988379fSRuoqing He- Developers who want to understand what log level to use and when,
6*9988379fSRuoqing He- Users who want to debug issues with running their workloads in Cloud Hypervisor
78824da27SRob Bradford
88824da27SRob Bradford## Control
98824da27SRob Bradford
107bf0cc1eSPhilipp SchusterThe number of `-v` parameters passed to the `cloud-hypervisor` binary will determine the log level. Currently the default is log messages up to `WARN:` (`warn!`) are included by default. The `--log-file` allows the log to be sent to a location other than `stderr`.
118824da27SRob Bradford
128824da27SRob Bradford## Levels
138824da27SRob Bradford
148824da27SRob Bradford### `error!()`
158824da27SRob Bradford
167bf0cc1eSPhilipp SchusterFor immediate, unrecoverable errors where it does not make sense for the execution to continue as the behaviour of the VM is considerably impacted.
178824da27SRob Bradford
188824da27SRob BradfordCloud Hypervisor should exit shortly after reporting this error (with a non-zero exit code). Generally this should be used during initial construction of the VM state before the virtual CPUs have begun running code.
198824da27SRob Bradford
208824da27SRob BradfordA typical situation where this might occur is when the user is using command line options that conflict with each other or is trying to use a file that is not present on the filesystem.
218824da27SRob Bradford
228824da27SRob BradfordUsers should react to this error by checking their initial VM configuration.
238824da27SRob Bradford
248824da27SRob Bradford### `warn!()`
258824da27SRob Bradford
267bf0cc1eSPhilipp SchusterA serious problem has occurred but the execution of the VM can continue although some functionality might be impacted.
278824da27SRob Bradford
288824da27SRob BradfordA typical example of where this level of message should be generated is during an API call request that cannot be fulfilled.
298824da27SRob Bradford
308824da27SRob BradfordThe user should investigate the meaning of this warning and take steps to ensure the correct functionality.
318824da27SRob Bradford
328824da27SRob Bradford### `info!()`
338824da27SRob Bradford
348824da27SRob BradfordUse `-v` to enable.
358824da27SRob Bradford
368824da27SRob BradfordThis level is for the benefit of developers. It should be used for sporadic and infrequent messages. The same message should not "spam" the logs. The VM should be usable when this level of debugging is enabled and trying to use `stdin/stdout` and the logs are going to `stderr`.
378824da27SRob Bradford
388824da27SRob Bradford### `debug!()`
398824da27SRob Bradford
40fa22cb0bSRavi kumar VeeramallyUse `-vv` to enable.
418824da27SRob Bradford
428824da27SRob BradfordFor the most verbose of logging messages. It is acceptable to "spam" the log with repeated invocations of the same message. This level of logging would be combined with `--log-file`.
43