WellDone/MoMo-Firmware — pull request #84 by amcgee (2014-05-23 14:07:43+00:00)
Title: Debug log

Implement a system log - you can write to the log in the following ways:

* `DEBUG_LOGL( "some literal string" )` - This will write a debug entry in the log with the literal string provided
* `CRITICAL_LOGL( "some literal string" )` - This will write a critical entry in the log with the literal string provided
* `DEBUG_LOG( some_buffer, buffer_len )` or `CRITICAL_LOG( some_buffer, buffer_len )` - Same as above but with an explicit length and support for runtime length calculation.
* `write_log( streamid, buffer, buffer_len )` - same as above but with explicit stream declaration - currently supported streams are kCriticalLog (1), kDebugLog (2) and kRemoteLog (3).
* `controller rpc -> 42, 0x20` - This will write a log entry in the `remote` stream.

You can read logs with RPC 42, 0x22 - this takes two integer arguments. The first is the index (0 through log count) and the second is the offset within the log structure (0 = header only, 1 = the first 20 bytes of the message, etc.)

The following python accessors have been added:
* `modtool log write` - writes a log entry in the remote stream
* `modtool log count` - get the total count of entries
* `modtool log read` - reads all of the log entries, beginning to end
* `modtool log lazy []` - gets or sets the lazy logging flag

Notes:
* Logs are tagged with a stream, length, and timestamped
* By default, logs are batched in memory and flushed to flash at a later time. There is a boolean value `lazy_system_logging` which can toggle this (it is volatile) and can be set via the RPC 42, 0x25
* There are 7 subsections of flash memory allocated for the system log. This means that old log entries will be overwritten once the total count exceeds 445 entries.
* The maximum size of the log message is 56 bytes (64 bytes with header information)