Arduino Playground is read-only starting December 31st, 2018. For more info please look at this Forum Post

Logging library for Arduino
by LunaX - 2010/2011

CURRENT VERSION

Rel 1.1 - 06-MAR-2012
Rel 1.0 - 24-FEB-2012 beta version.

HISTORY

1.1 06-MAR-2012 preinitial object available (like in Wire lib)
1.0 24-FEB-2012 Initial Release

DESCRIPTION

Easy to use logging library, like log4j or log4net. After getting a logger object, you will have methods like Error, Info, Warn, Debug, Verbose to log informations over RS232. Depending on the current loglevel lower logleves are not printed out. It is possible to work with variable argument lists during output. Detailed description is included in doc folder

HOW TO IMPORT/INSTALL

Download zip file here https://github.com/mrRobot62/Arduino-logging-library

Put the Logging folder in "libraries\".

Open example project which is included in the zip file. Try it, like it :-)

Some benefits:

Use formated strings with wildcards

wildcardCommentExample
%sreplace with an string (char*)logger.Info("String %s",myString);
%creplace with an characterlogger.Info("use %c as input",myChar);
%dreplace with an integer valuelogger.Info("current value %d",myValue);
%lreplace with an long valuelogger.Info("current long %l",myLong);
%xreplace and convert integer value into hexlogger.Info ("as hex %x), myValue);
%Xlike %x but combine with 0x123ABlogger.Info ("as hex %X), myValue);
%breplace and convert integer value into binarylogger.Info ("as bin %b), myValue);
%Blike %x but combine with 0b10100011logger.Info ("as bin %B), myValue);
%treplace and convert boolean value into "t" or "f"logger.Info ("is it true? %t), myBool);
%Tlike %t but convert into "true" or "false"logger.Info ("is it true? %T), myBool);

Methods for output

MethodeComment
Initinitialize logger
Errorprint messages with loglevel >= LOGLEVEL_ERROR
Infoprint messages with loglevel >= LOGLEVEL_INFO
Debugprint messages with loglevel >= LOGLEVEL_DEBUG
Verboseprint messages with loglevel >= LOGLEVEL_VERGBOSE

Saving Your Log to a File

If you want to save logged data to a text file use Teraterm or Megunolink. http://megunolink.com