Last active
August 29, 2015 14:15
-
-
Save ElectricImpSampleCode/9d30111c523b781dec2a to your computer and use it in GitHub Desktop.
Squirrel class for logging via UART
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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