docs/doc/source/develop/service-logging-conventions.rst
Drew Walters bc6b004dba Restructure Documentation
This change restructures the documentation into three categories that we
will expand on later:

  1. Try Airship
  2. Develop Airship
  3. Learn About Airship

Change-Id: I52286c3b1d87222a436be86b4ab748dba61d080c
Signed-off-by: Drew Walters <andrew.walters@att.com>
2020-03-02 16:04:01 +00:00

2.3 KiB

Service Logging Conventions

Airship services must provide logging, should conform to a standard logging format, and may utilize shared code to do so.

Standard Logging Format

The following is the intended format to be used when logging from Airship services. When logging from those parts that are no services, a close reasonable approximation is desired.

Timestamp Level RequestID ExternalContextID ModuleName(Line) Function - Message

Where:

  • Timestamp is like 2006-02-08 22:20:02,165, or the standard ouptut from %(asctime)s
  • Level is 'DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL', padded to 8 characters, left aligned.
  • RequestID is the UUID assigned to the request in canonical 8-4-4-4-12 format.
  • ExternalContextID is the UUID assigned from the external source (or generated for the same purpose), in 8-4-4-4-12 format.
  • ModuleName is the name of the module or class from which the logging originates.
  • Line is the line number of the logging statement
  • Function is the name of the function or method from which the logging originates
  • Message is the text of the message to be logged.

Example Python Logging Format

%(asctime)s %(levelname)-8s %(req_id)s %(external_ctx)s %(user)s %(module)s(%(lineno)d) %(funcName)s - %(message)s'

See Python Logging for explanation of format.

Loggers in Code

Components should prefer loggers that are at the module or class level, allowing for finer grained logging control than a global logger.