#include "SFBTypes.h"
#include <stdarg.h>


Go to the source code of this file.
Enumerations | |
| enum | LoggingLevels { LOGLEVEL_NONE, LOGLEVEL_QUIET, LOGLEVEL_NORMAL, LOGLEVEL_VERBOSE, LOGLEVEL_DEBUG } |
Functions | |
| void | setLogLevel (int n) |
| Set the logging level to n. | |
| int | getLogLevel () |
| Return the current logging level. | |
| void | setLogFace (u8 face) |
| Set the log face. | |
| u8 | getLogFace () |
| Return the current log face. | |
| void | pprintf (const char *format,...) |
| Convenience shorthand for printing to all available physical faces. | |
| void | facePrintf (u8 face, const char *format,...) |
| Formatted printing to the specified face. | |
| void | vfacePrintf (u8 face, const char *format, va_list &ap) |
Formatted printing to the specified face, through a supplied va_list. | |
| u32 | packetScanf (u8 *packet, const char *format,...) |
| Formatted reading from a packet into individual variables. | |
| u32 | vPacketScanf (u8 *packet, const char *format, va_list &ap) |
| void | vfaceLogf (int includeTimestamp, int level, u8 face, const char *format, va_list &ap) |
| void | logf (int level, const char *format,...) |
| void | logNormal (const char *format,...) |
| If getLogLevel() is at least LOGLEVEL_NORMAL, print "Ln " plus a timestamp, plus as directed by format, to the current getLogFace(). | |
| void | logVerbose (const char *format,...) |
| If getLogLevel() is at least LOGLEVEL_VERBOSE, print "Lv " plus a timestamp, plus as directed by format, to the current getLogFace(). | |
| void | logDebug (const char *format,...) |
| If getLogLevel() is at least LOGLEVEL_DEBUG, print "Ld " plus a timestamp, plus as directed by format, to the current getLogFace(). | |
| void | logQuiet (const char *format,...) |
| If getLogLevel() is at least LOGLEVEL_QUIET, print "Lq " plus a timestamp, plus as directed by format, to the current getLogFace(). | |
| void | msgf (int level, const char *format,...) |
| void | msgNormal (const char *format,...) |
| If getLogLevel() is at least LOGLEVEL_NORMAL, print "Lq " plus as directed by format, to the current getLogFace(). | |
| void | msgVerbose (const char *format,...) |
| If getLogLevel() is at least LOGLEVEL_VERBOSE, print "Lv " plus as directed by format, to the current getLogFace(). | |
| void | msgDebug (const char *format,...) |
| If getLogLevel() is at least LOGLEVEL_DEBUG, print "Ld " plus as directed by format, to the current getLogFace(). | |
| void | msgQuiet (const char *format,...) |
| If getLogLevel() is at least LOGLEVEL_QUIET, print "Lq " plus as directed by format, to the current getLogFace(). | |
| enum LoggingLevels |
| LOGLEVEL_NONE | When passed to setLogLevel(int), suppress all logging output. |
| LOGLEVEL_QUIET | When passed to setLogLevel(int), allow less than normal logging output. |
| LOGLEVEL_NORMAL | When passed to setLogLevel(int), allow normal logging output. |
| LOGLEVEL_VERBOSE | When passed to setLogLevel(int), allow more than normal logging output. |
| LOGLEVEL_DEBUG | When passed to setLogLevel(int), allow all logging output. |
| void facePrintf | ( | u8 | face, | |
| const char * | format, | |||
| ... | ||||
| ) |
Formatted printing to the specified face.
| face | the face code to which the printing shall be directed. This may be a "physical face" code like WEST, an "extended face" code like BRAIN or ALL_FACES or NO_FACES, or a sketch-defined "virtual face" code (such as produced by faceFindFreeFace() and faceSetPrinter()). | |
| format | a null-terminated string controlling what is to be printed; see below. | |
| ... | a variable sequence of arguments of sufficient number and appropriate types to supply to all of the "% codes" in format with the data they need. |
printf functions, but with many restrictions -- for example, there is only limited support for 'field widths'. There are also a few SFB-specific extensions. This documentation presumes familiarity with the use of printf-like functions in general, and only documents the specifics of the SFB format codes.Quick format reference. The following 'percent escape' codes are recognized:
The '#' modifier character may be added to certain conversions to achieve special purposes, as follows:
Since 0.9.7, there is limited support for field widths (a.k.a. padding and filling), with the following restrictions:
XXX Still need formatting details; examples.
| u8 getLogFace | ( | ) |
Return the current log face.
See setLogFace(u8) for details.
| int getLogLevel | ( | ) |
Return the current logging level.
See setLogLevel(int) for details.
| void logDebug | ( | const char * | format, | |
| ... | ||||
| ) |
If getLogLevel() is at least LOGLEVEL_DEBUG, print "Ld " plus a timestamp, plus as directed by format, to the current getLogFace().
Otherwise do nothing.
| void logNormal | ( | const char * | format, | |
| ... | ||||
| ) |
If getLogLevel() is at least LOGLEVEL_NORMAL, print "Ln " plus a timestamp, plus as directed by format, to the current getLogFace().
Otherwise do nothing.
| void logQuiet | ( | const char * | format, | |
| ... | ||||
| ) |
If getLogLevel() is at least LOGLEVEL_QUIET, print "Lq " plus a timestamp, plus as directed by format, to the current getLogFace().
Otherwise do nothing.
| void logVerbose | ( | const char * | format, | |
| ... | ||||
| ) |
If getLogLevel() is at least LOGLEVEL_VERBOSE, print "Lv " plus a timestamp, plus as directed by format, to the current getLogFace().
Otherwise do nothing.
| void msgDebug | ( | const char * | format, | |
| ... | ||||
| ) |
If getLogLevel() is at least LOGLEVEL_DEBUG, print "Ld " plus as directed by format, to the current getLogFace().
Otherwise do nothing.
| void msgNormal | ( | const char * | format, | |
| ... | ||||
| ) |
If getLogLevel() is at least LOGLEVEL_NORMAL, print "Lq " plus as directed by format, to the current getLogFace().
Otherwise do nothing.
| void msgQuiet | ( | const char * | format, | |
| ... | ||||
| ) |
If getLogLevel() is at least LOGLEVEL_QUIET, print "Lq " plus as directed by format, to the current getLogFace().
Otherwise do nothing.
| void msgVerbose | ( | const char * | format, | |
| ... | ||||
| ) |
If getLogLevel() is at least LOGLEVEL_VERBOSE, print "Lv " plus as directed by format, to the current getLogFace().
Otherwise do nothing.
Formatted reading from a packet into individual variables.
Scanning starts at the current packetCursor() of packet, not necessarily at the beginning, and the packetCursor() of packet is advanced as scanning proceeds.
| packet | The packet that is to be scanned. | |
| format | a null-terminated string controlling what is to be printed; see below. | |
| ... | a variable sequence of pointer arguments of sufficient number and appropriate types through which to store values for all the "% codes" in format that require arguments. |
void MyBHandler(u8 * packet) { u32 fourBytes; u16 twoBytes; u8 oneByte; if (packetScanf(packet,"b%c%d%h",&oneByte,&fourBytes,&twoBytes) != 4) return; .. }
oneByte, fourBytes, and twoBytes variables match the specified sizes of %c, %d, and %h, respectively.Since 0.9.9, there is some support for field widths, limited to the %b, %o, %d, %x, and %t conversions only.
packetScanf returns the number of successful matches it made, where a 'match' counts as either a successful '% conversion' or a successful match of a single literal byte of the format string. E.g., given a packet containing "fg123h", packetScanf(packet,"fg%dh",&u32var) will return 4 -- one for the 'f', one for the 'g', one for the '%d', and one for the 'h'. (But watch out! Given the same packet, packetScanf(packet,"fg%dh\n",&u32var) will return 5 -- including one for the successful matching of the end-of-packet!)
XXX Still need formatting details; examples.
| void pprintf | ( | const char * | format, | |
| ... | ||||
| ) |
Convenience shorthand for printing to all available physical faces.
Equivalent to facePrintf(ALL_FACES, format, ...), which see for details of the possible format codes.
| void setLogFace | ( | u8 | face | ) |
Set the log face.
Using this function, logging messages can be directed to any (physical or virtual) face. Default value: ALL_FACES
| void setLogLevel | ( | int | n | ) |
Set the logging level to n.
Larger values produce more output, smaller values produce less. Initial value is LOGLEVEL_NORMAL.
| n | Logging level. Can be any int, but only the values LOGLEVEL_NONE, LOGLEVEL_QUIET, LOGLEVEL_NORMAL, LOGLEVEL_VERBOSE, LOGLEVEL_DEBUG really make much sense. |
| void vfacePrintf | ( | u8 | face, | |
| const char * | format, | |||
| va_list & | ap | |||
| ) |
Formatted printing to the specified face, through a supplied va_list.
See facePrintf(u8 face, const char * format, ...) for details of arguments face and format.