Let us use a example of volume provisioning workflow in maya-apiserver to understand and define the different log levels that should be used.
Fatal -- maya-apiserver is unable to determine the orchestration provider, so there is no point in continuing further. log the message and exit
Error -- maya-apiserver is unable to contact the kuberentes-apiserver at the moment, log the message and return error to the caller
Warn -- maya-apiserver volume is being provisioned with values that are not optimal
Info -- maya-apiserver was able to successfully provision an volume - display the name of the volume.
Info(V2) -- log the messages that show the various stages in the volume provisioning
Info(V3) -- log the code level entry/exit and print data/variables
Once finalized, the logging convention should be recorded in the following link:
https://github.com/openebs/openebs/blob/master/contribute/design/code-structuring.md
Let us use a example of volume provisioning workflow in maya-apiserver to understand and define the different log levels that should be used.
Fatal -- for exiting when an unexpected unrecoverable error fault
Fatal -- maya-apiserver is unable to determine the orchestration provider, so there is no point in continuing further. log the message and exit
error & exit is appropriate here. Error -- maya-apiserver is unable to contact the kuberentes-apiserver at the moment, log the message and return error to the caller
WARN -- maya-apiserver volume is being provisioned with values that are not optimal
WARN -- is usually when some threshold situations are seen or borderline situations .. like long time to provision or running low on memory .. or about to perform some operation that shouldn't be done
Info -- maya-apiserver was able to successfully provision an volume - display the name of the volume.
Info(V2) -- log the messages that show the various stages in the volume provisioning
Info(V3) -- log the code level entry/exit and print data structure
An example of warning could be running the service or exposing the service on a non-secure port. This message will not appear if the user only runs the service with secure port.
The following conventions for the glog levels to use.
glog.Errorf() - Always an error
glog.Warningf() - Something unexpected, but probably not an error
glog.Infof() has multiple levels:
glog.V(0) - Generally useful for this to ALWAYS be visible to an operator
Programmer errors
Logging extra info about a panic
CLI argument handling
glog.V(1) - A reasonable default log level if you don't want verbosity.
Information about config (listening on X, watching Y)
Errors that repeat frequently that relate to conditions that can be corrected (pod detected as unhealthy)
glog.V(2) - Useful steady state information about the service and important log messages that may correlate to significant changes in the system. This is the recommended default log level for most systems.
Logging HTTP requests and their exit code
System state changing (killing pod)
Controller state change events (starting pods)
Scheduler log messages
glog.V(3) - Extended information about changes
More info about system state changes
glog.V(4) - Debug level verbosity (for now)
Logging in particularly thorny parts of code where you may want to come back later and check it
As per the comments, the practical default level is V(2). Developers and QE environments may wish to run at V(3) or V(4). If you wish to change the log level, you can pass in -v=X where X is the desired maximum level to log.
Issues go stale after 90d of inactivity.
Most helpful comment
A request lifecycle in maya api service:
error & exitis appropriate here.Other Notes