Aldebaran documentation What's new in NAOqi 2.4.3?

qi.logging API

Introduction

This module provides logging capabilities integrated with the qi sdk.

Warning

The debug log level is not available in python, because there is no debug build in python. Use verbose instead.

There are two ways to use this module:

Class qi.Logger Reference

class qi.Logger(category)
error(mess, *args) → None
Parameters:
  • mess – Messages string
  • *args – Arguments are interpreted as for qi.Logger.fatal().

Logs a message with level ERROR on this logger.

fatal(mess, *args) → None
Parameters:
  • mess – Messages string
  • *args – Messages format string working the same way as python function print.

Logs a message with level FATAL on this logger.

info(mess, *args) → None
Parameters:
  • mess – Messages string
  • *args – Arguments are interpreted as for qi.Logger.fatal().

Logs a message with level INFO on this logger.

verbose(mess, *args) → None
Parameters:
  • mess – Messages string
  • *args – Arguments are interpreted as for qi.Logger.fatal().

Logs a message with level VERBOSE on this logger.

warning(mess, *args) → None
Parameters:
  • mess – Messages string
  • *args – Arguments are interpreted as for qi.Logger.fatal().

Logs a message with level WARNING on this logger.

Example

With a defined category:

import qi

mylogger = qi.Logger("myfoo.bar")

mylogger.warning("my log message")

Static Methods Reference

qi.fatal(cat, mess, *args) → None
Parameters:
  • cat – The category is potentially a period-separated hierarchical value.
  • mess – Messages string
  • *args – Messages format string working the same way as print python function.

Logs a message with level FATAL.

qi.error(cat, mess, *args) → None
Parameters:
  • cat – The category is potentially a period-separated hierarchical value.
  • mess – Messages string
  • *args – Messages format string working the same way as print python function.

Logs a message with level ERROR.

qi.warning(cat, mess, *args) → None
Parameters:
  • cat – The category is potentially a period-separated hierarchical value.
  • mess – Messages string
  • *args – Messages format string working the same way as print python function.

Logs a message with level WARNING.

qi.info(cat, mess, *args) → None
Parameters:
  • cat – The category is potentially a period-separated hierarchical value.
  • mess – Messages string
  • *args – Messages format string working the same way as print python function.

Logs a message with level INFO.

qi.verbose(cat, mess, *args) → None
Parameters:
  • cat – The category is potentially a period-separated hierarchical value.
  • mess – Messages string
  • *args – Messages format string working the same way as print python function.

Logs a message with level VERBOSE.

Deprecated Methods

qi.getLogger()

Deprecated since version 2.0.1: Please use qi.Logger() instead

qi.logFatal()

Deprecated since version 2.0.1: Please use qi.fatal() instead

qi.logError()

Deprecated since version 2.0.1: Please use qi.error() instead

qi.logWarning()

Deprecated since version 2.0.1: Please use qi.warning() instead

qi.logInfo()

Deprecated since version 2.0.1: Please use qi.info() instead

qi.logVerbose()

Deprecated since version 2.0.1: Please use qi.verbose() instead

qi.logDebug()

Deprecated since version 2.0.1: Please use qi.verbose() instead

Example

Simple example:

import qi

qi.warning("myfoo.bar", "my log message")

Simple example with a category:

import qi

log = qi.Logger("myfoo.bar")
log.warning("my log message")

Reference

Global methods

qi.logging.setFilters(filters) → None
Parameters:filters – List of rules separated by colon.

Set log filtering options. Each rule can be:

+CAT: enable category CAT

-CAT: disable category CAT

CAT=level : set category CAT to level

Each category can include a ‘*’ for globbing.

qi.logging.setFilter("qi.*=debug:-qi.foo:+qi.foo.bar")

(all qi.* logs in info, remove all qi.foo logs except qi.foo.bar)

qi.logging.setLevel(level) → None
Parameters:level – The logger level need to be choose between FATAL, ERROR, WARNING, INFO, VERBOSE, DEBUG

Sets the threshold for the logger to level. Logging messages which are less severe than level will be ignored. Note that the logger is created with level INFO.

qi.logging.setContext(context) → None
Parameters:context – A bitfield (add values descibe below).

1 : Verbosity

2 : ShortVerbosity

4 : Date

8 : ThreadId

16 : Category

32 : File

64 : Function

128: EndOfLine

Some useful values for context are:

26 : (verb+threadId+cat)

30 : (verb+threadId+date+cat)

126: (verb+threadId+date+cat+file+fun)

254: (verb+threadId+date+cat+file+fun+eol)