Overview

This module allows you log errors, warnings, and info to syslog, stdout or a file. The verbosity level and/or filter allow you to customize the output.

Methods

void separator ()

output a simple line separator

Example in c++ :

  ALLoggerProxy* log;
  try
  {
    log = new ALLoggerProxy();
    log->separator();
  }
  catch(const ALError&)
  {
    std::cout << "error during initialisation" << std::endl;
  }
  delete log;

Example in Python :

  # Print a separator 
  log = ALProxy("ALLogger", "127.0.0.1", 9559)
  log.separator()

void fatal (const string& moduleName, const string& message)

Log a fatal error.

moduleName

Name of the module.

message

Log Message.

Example in Python :

  # Print a fatal message
  log = ALProxy("ALLogger", "127.0.0.1", 9559)
  log.fatal("moduleName", "message")

void error (const string& moduleName, const string& message)

Log an error.

moduleName

Name of the module.

message

Log Message.

Example in Python :

  # Print an error message
  log = ALProxy("ALLogger", "127.0.0.1", 9559)
  log.error("moduleName", "message")

void warn (const string& moduleName, const string& message)

Log a warning.

moduleName

Name of the module.

message

Log Message.

Example in Python :

  # Print a warning message
  log = ALProxy("ALLogger", "127.0.0.1", 9559)
  log.warn("moduleName", "message")

void info (const string& moduleName, const string& message)

Log a info message.

moduleName

Name of the module.

message

Log Message.

Example in Python :

  # Print an info message
  log = ALProxy("ALLogger", "127.0.0.1", 9559)
  log.info("moduleName", "message")

void lowInfo (const string& moduleName, const string& message)

DEPRECIATED: Log a low priority information message. Use info instead.

moduleName

Name of the module.

message

Log Message.

void debug (const string& moduleName, const string& message)

Log a debug message.

moduleName

Name of the module.

message

Log Message.

Example in Python :

  # Print an debug message
  log = ALProxy("ALLogger", "127.0.0.1", 9559)
  log.debug("moduleName", "message")

void lowDebug (const string& moduleName, const string& message)

DEPRECIATED: Log a low priority debug message. Use debug instead.

moduleName

Name of the module.

message

Log Message.

void setVerbosity (const string& verbosity)

set verbosity: debug, info, warning, error, fatal, silent. Default is info

verbosity

verbosity value

Example in Python :

  # Set the verbosity to debug 
  log = ALProxy("ALLogger", "127.0.0.1", 9559)
  log.setVerbosity("debug")
  log.debug("moduleName", "message")

Example in Python :

  # Set the verbosity to warning 
  log = ALProxy("ALLogger", "127.0.0.1", 9559)
  log.setVerbosity("warning")
  # This message will not be seen in the log
  log.info("moduleName", "info message, not seen")
  # But this one will be
  log.warn("moduleName", "warning message")

void setFilter (const string& filter)

Creates a filter. Only messages containing the string will be logged. Use an empty string to remove the filter.

filter

The string that defines the filter.

Example in Python :

  # Filter messages
  log = ALProxy("ALLogger", "127.0.0.1", 9559)
  log.setFilter("rain")
  # This message will be seen:
  log.fatal("moduleName", "It is raining")
  # But this one will not:
  log.fatal("moduleName", "It is sunny")
  # Remove the filter
  log.setFilter("")

void logInFile (const string& fileName)

Allows the logger to store logs in a file. Warning: this is not recomended on Nao.

fileName

The fileName to use. Relative to the user naoqi folder.

Example in Python :

  # Start logging to file.
  # Note: it is not recommended to log to file on Nao.
  log = ALProxy("ALLogger", "127.0.0.1", 9559)
  log.logInFile("fileName.txt")

void logInStd ()

Allows the logger to output logs to the standard output.

Example in Python :

  # Send output to console
  log = ALProxy("ALLogger", "127.0.0.1", 9559)
  log.logInStd()

void logInSys ()

Allows the logger to output logs to the system log. (Linux only)

Example in Python :

  # Send output to syslog, on platforms that support this
  log = ALProxy("ALLogger", "127.0.0.1", 9559)
  log.logInSys()

void logInForwarder (const string& inputAddress)

Publish logs to a Log Forwarder. Pass an empty string in order to use the default value: "tcp://localhost:50998"

inputAddress

Desired input ZMQ address of the Log Forwarder.

Example in Python :

  log = ALProxy("ALLogger", "127.0.0.1", 9559)
  log.logInForwarder("tcp://localhost:50998")

void removeHandler (const string& id)

Unsubscribe specified id from connection list.

id

Id used to register the handler.

Example in Python :

  log = ALProxy("ALLogger", "127.0.0.1", 9559)
  log.removeConnection("MyLogger")


Methods inherited from ALModule

void exit ()

Exits and unregisters the module.

string version ()

Returns the version of the module.

Returns

A string containing the version of the module.

bool ping ()

Just a ping. Always returns true

Returns

returns true

vector<string> getMethodList ()

Retrieves the module's method list.

Returns

An array of method names.

AL::ALValue getMethodHelp (const string& methodName)

Retrieves a method's description.

methodName

The name of the method.

Returns

A structure containing the method's description.

AL::ALValue getModuleHelp ()

Retrieves the module's description.

Returns

A structure describing the module.

string getBrokerName ()

Gets the name of the parent broker.

Returns

The name of the parent broker.

string getUsage (const string& name)

Gets the method usage string. This summarise how to use the method.

name

The name of the method.

Returns

A string that summarises the usage of the method.


Example Code

Example in c++ :

   try
   {
      getParentBroker()->getLoggerProxy()->info("MyModule", "This is an info message");
   }
   catch(const ALError &e)
   {
    std::cout << "Error when using ALLogger: " + e.toString() << std::endl;
   }

Example in Python :

   import naoqi
   from naoqi import ALProxy
   log = ALProxy("ALLogger", "127.0.0.1", 9559)
   log.info("MyModule", "This is a info message");

Copyright © 2010 Aldebaran Robotics - All rights reserved