xref: /cloud-hypervisor/docs/logging.md (revision 1968805ba291ae08e07abf0ef8c0ade4cf11ab68)
1# Logging
2
3The target audience of this document is both:
4
5- Developers who want to understand what log level to use and when,
6- Users who want to debug issues with running their workloads in Cloud Hypervisor
7
8## Control
9
10The 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`.
11
12## Levels
13
14### `error!()`
15
16For immediate, unrecoverable errors where it does not make sense for the execution to continue as the behaviour of the VM is considerably impacted.
17
18Cloud 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.
19
20A 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.
21
22Users should react to this error by checking their initial VM configuration.
23
24### `warn!()`
25
26A serious problem has occurred but the execution of the VM can continue although some functionality might be impacted.
27
28A typical example of where this level of message should be generated is during an API call request that cannot be fulfilled.
29
30The user should investigate the meaning of this warning and take steps to ensure the correct functionality.
31
32### `info!()`
33
34Use `-v` to enable.
35
36This 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`.
37
38### `debug!()`
39
40Use `-vv` to enable.
41
42For 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