Skip to content

Instantly share code, notes, and snippets.

@ElectricImpSampleCode
Last active August 29, 2015 14:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ElectricImpSampleCode/9d30111c523b781dec2a to your computer and use it in GitHub Desktop.
Save ElectricImpSampleCode/9d30111c523b781dec2a to your computer and use it in GitHub Desktop.
Squirrel class for logging via UART
class Logger {
_serial = null;
constructor (impUART) {
if (impUART != null) {
_serial = impUART;
_serial.configure(115200, 8, PARITY_NONE, 1, NO_RX);
}
}
function write(message = "") {
if (message == "" || message == null) return;
local now = date();
local timestamp = format("%u-%u-%u %u:%u ", now.year, now.month, now.day, now.hour, now.min);
_serial.write(timestamp + message + "\r\n");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment