Aria  2.8.0
ArLog Class Reference

Logging utility class. More...

#include <ArLog.h>

Public Types

enum  LogLevel { Terse, Normal, Verbose }
 
enum  LogType {
  StdOut, StdErr, File, Colbert,
  None
}
 

Static Public Member Functions

static void addToConfig (ArConfig *config)
 Use an ArConfig object to control ArLog's options.
 
static void aramInit (const char *prefix, ArLog::LogLevel defaultLevel=ArLog::Normal, double defaultSize=10, bool daemonized=false)
 Init for aram behavior.
 
static void close ()
 Close the logging utility.
 
static bool init (LogType type, LogLevel level, const char *fileName="", bool logTime=false, bool alsoPrint=false, bool printThisCall=true)
 Initialize the logging utility with options. More...
 
static void internalForceLockup (void)
 Internal function to force a lockup, only for debugging.
 
static void log (LogLevel level, const char *str,...)
 Log a message, with formatting and variable number of arguments. More...
 
static void logBacktrace (LogLevel level)
 If possible (only in Linux right now) log the backtrace.
 
static void logErrorFromOS (LogLevel level, const char *str,...)
 Logs an error, adding the error and string the error mean at the end of this message. More...
 
static void logErrorFromOSNoLock (LogLevel level, const char *str,...)
 Logs an error, adding the error and string the error mean at the end of this message... More...
 
static void logErrorFromOSPlain (LogLevel level, const char *str)
 Logs an error, adding the error and string the error mean at the end of this message. More...
 
static void logErrorFromOSPlainNoLock (LogLevel level, const char *str)
 Logs an error, adding the error and string the error mean at the end of this message... More...
 
static void logNoLock (LogLevel level, const char *str,...)
 
static void logPlain (LogLevel level, const char *str)
 Log a message containing just a plain string.
 
static void setFunctor (ArFunctor1< const char *> *functor)
 Internal functor to be called when a log message is made (this shouldn't really be used)
 

Static Public Attributes

static void(* colbertPrint )(int i, const char *str)
 

Static Protected Member Functions

static bool aramProcessFile (void)
 
static void checkFileSize (void)
 
static void filledAramLog (void)
 
static void invokeFunctor (const char *message)
 
static bool processFile (void)
 

Static Protected Attributes

static bool ourAlsoPrint = false
 
static char ourAramConfigLogLevel [1024] = "Normal"
 
static double ourAramConfigLogSize = 10
 
static ArGlobalRetFunctor< bool > ourAramConfigProcessFileCB
 
static bool ourAramDaemonized = false
 
static double ourAramLogSize = 0
 
static std::string ourAramPrefix = ""
 
static int ourCharsLogged = 0
 
static int ourColbertStream = -1
 
static bool ourConfigAlsoPrint = false
 
static char ourConfigFileName [1024] = "log.txt"
 
static LogLevel ourConfigLogLevel = ArLog::Normal
 
static bool ourConfigLogTime = false
 
static LogType ourConfigLogType = ArLog::StdOut
 
static ArGlobalRetFunctor< bool > ourConfigProcessFileCB
 
static std::string ourFileName
 
static FILE * ourFP =0
 
static ArFunctor1< const char * > * ourFunctor
 
static LogLevel ourLevel =ArLog::Normal
 
static ArLogourLog
 
static bool ourLoggingTime = false
 
static ArMutex ourMutex
 
static LogType ourType =StdOut
 
static bool ourUseAramBehavior = false
 

Detailed Description

Logging utility class.

ArLog is a utility class to log all messages from Aria to a choosen destintation. Messages can be logged to stdout, stderr, a file, and turned off completely. Logging by default is set to stdout. The level of logging can be changed as well. Allowed levels are Terse, Normal, and Verbose. By default the level is set to Normal.

Member Enumeration Documentation

◆ LogLevel

Enumerator
Terse 

Use terse logging.

Normal 

Use normal logging.

Verbose 

Use verbose logging.

◆ LogType

Enumerator
StdOut 

Use stdout for logging.

StdErr 

Use stderr for logging.

File 

Use a file for logging.

Colbert 

Use a Colbert stream for logging.

None 

Disable logging.

Member Function Documentation

◆ init()

bool ArLog::init ( LogType  type,
LogLevel  level,
const char *  fileName = "",
bool  logTime = false,
bool  alsoPrint = false,
bool  printThisCall = true 
)
static

Initialize the logging utility with options.

Initialize the logging utility by supplying the type of logging and the level of logging.

If the type is File, the fileName needs to be supplied.

Parameters
typetype of Logging
levellevel of logging
fileNamethe name of the file for File type of logging
logTimeif this is true then the time a message is given will be logged
alsoPrintif this is true then in addition to whatever other logging (to a file for instance) the results will also be printed
printThisCallif this is true the new settings will be printed otherwise they won't
Examples:
gpsExample.cpp, gpsRobotTaskExample.cpp, imuExample.cpp, laserConnect.cpp, and lasers.cpp.

◆ log()

void ArLog::log ( LogLevel  level,
const char *  str,
  ... 
)
static

Log a message, with formatting and variable number of arguments.

This function is used like printf().

Java and Python Wrappers: In Java and Python, this function only takes one string argument. Use Java or Python's native facities for constructing a formatted string, e.g. the % and + string operators in Python, and the methods of the Java String class.

If the supplied level is less than or equal to the set level, it will be printed.

Parameters
levellevel of logging
strprintf() like formating string
Examples:
actionExample.cpp, actionGroupExample.cpp, actsColorFollowingExample.cpp, armExample.cpp, auxSerialExample.cpp, cameraPTZExample.cpp, configExample.cpp, demo.cpp, directMotionExample.cpp, dpptuExample.cpp, gotoActionExample.cpp, gpsExample.cpp, gpsRobotTaskExample.cpp, gripperExample.cpp, gyroExample.cpp, imuExample.cpp, laserConnect.cpp, lasers.cpp, lineFinderExample.cpp, moduleExample.cpp, moduleExample_Mod.cpp, mtxIO.cpp, mtxLCDDisplay.cpp, mtxPowerControl.cpp, mtxWheelLights.cpp, robotConnectionCallbacks.cpp, seekurPower.cpp, simpleConnect.cpp, simpleMotionCommands.cpp, socketClientExample.cpp, socketServerExample.cpp, teleopActionsExample.cpp, threadExample.cpp, and wander.cpp.

◆ logErrorFromOS()

void ArLog::logErrorFromOS ( LogLevel  level,
const char *  str,
  ... 
)
static

Logs an error, adding the error and string the error mean at the end of this message.

This function appends errorno in linux, or getLastError in windows, and a string indicating the problem.

Parameters
levellevel of logging
strprintf() like formating string

◆ logErrorFromOSNoLock()

void ArLog::logErrorFromOSNoLock ( LogLevel  level,
const char *  str,
  ... 
)
static

Logs an error, adding the error and string the error mean at the end of this message...

This function appends errorno in linux, or getLastError in windows, and a string indicating the problem.

internal version, don't use it

Parameters
levellevel of logging
strprintf() like formating string

◆ logErrorFromOSPlain()

void ArLog::logErrorFromOSPlain ( LogLevel  level,
const char *  str 
)
static

Logs an error, adding the error and string the error mean at the end of this message.

This function appends errorno in linux, or getLastError in windows, and a string indicating the problem.

Parameters
levellevel of logging
strprintf() like formating string

◆ logErrorFromOSPlainNoLock()

void ArLog::logErrorFromOSPlainNoLock ( LogLevel  level,
const char *  str 
)
static

Logs an error, adding the error and string the error mean at the end of this message...

This function appends errorno in linux, or getLastError in windows, and a string indicating the problem.

internal version, dont' use it

Parameters
levellevel of logging
strprintf() like formating string

The documentation for this class was generated from the following files: