ACKme
/
wiconnect-test-console
Test serial console demonstrating various API functions of WiConnect library.
util/log/log.cpp@0:836c9a6383e0, 2014-08-11 (annotated)
- Committer:
- dan_ackme
- Date:
- Mon Aug 11 11:31:32 2014 +0000
- Revision:
- 0:836c9a6383e0
- Child:
- 1:5137ec8f4c45
Initial check-in
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
dan_ackme | 0:836c9a6383e0 | 1 | /* |
dan_ackme | 0:836c9a6383e0 | 2 | * Copyright 2014, ACKme Networks |
dan_ackme | 0:836c9a6383e0 | 3 | * All Rights Reserved. |
dan_ackme | 0:836c9a6383e0 | 4 | * |
dan_ackme | 0:836c9a6383e0 | 5 | * This is UNPUBLISHED PROPRIETARY SOURCE CODE of ACKme Networks; |
dan_ackme | 0:836c9a6383e0 | 6 | * the contents of this file may not be disclosed to third parties, copied |
dan_ackme | 0:836c9a6383e0 | 7 | * or duplicated in any form, in whole or in part, without the prior |
dan_ackme | 0:836c9a6383e0 | 8 | * written permission of ACKme Networks. |
dan_ackme | 0:836c9a6383e0 | 9 | */ |
dan_ackme | 0:836c9a6383e0 | 10 | |
dan_ackme | 0:836c9a6383e0 | 11 | #include <stdio.h> |
dan_ackme | 0:836c9a6383e0 | 12 | #include <stdarg.h> |
dan_ackme | 0:836c9a6383e0 | 13 | |
dan_ackme | 0:836c9a6383e0 | 14 | |
dan_ackme | 0:836c9a6383e0 | 15 | #include "Wiconnect.h" |
dan_ackme | 0:836c9a6383e0 | 16 | #include "log.h" |
dan_ackme | 0:836c9a6383e0 | 17 | #include "util/CommandProcessor/CommandProcessor.h" |
dan_ackme | 0:836c9a6383e0 | 18 | |
dan_ackme | 0:836c9a6383e0 | 19 | |
dan_ackme | 0:836c9a6383e0 | 20 | extern ConsoleSerial consoleSerial; |
dan_ackme | 0:836c9a6383e0 | 21 | |
dan_ackme | 0:836c9a6383e0 | 22 | |
dan_ackme | 0:836c9a6383e0 | 23 | /*************************************************************************************************/ |
dan_ackme | 0:836c9a6383e0 | 24 | void logDebug(const char *msg, ...) |
dan_ackme | 0:836c9a6383e0 | 25 | { |
dan_ackme | 0:836c9a6383e0 | 26 | va_list args; |
dan_ackme | 0:836c9a6383e0 | 27 | |
dan_ackme | 0:836c9a6383e0 | 28 | consoleSerial.write("[DEBUG] "); |
dan_ackme | 0:836c9a6383e0 | 29 | va_start(args, msg); |
dan_ackme | 0:836c9a6383e0 | 30 | consoleSerial.vprintf(msg, args); |
dan_ackme | 0:836c9a6383e0 | 31 | va_end(args); |
dan_ackme | 0:836c9a6383e0 | 32 | } |
dan_ackme | 0:836c9a6383e0 | 33 | |
dan_ackme | 0:836c9a6383e0 | 34 | /*************************************************************************************************/ |
dan_ackme | 0:836c9a6383e0 | 35 | void logInfo(const char *msg, ...) |
dan_ackme | 0:836c9a6383e0 | 36 | { |
dan_ackme | 0:836c9a6383e0 | 37 | va_list args; |
dan_ackme | 0:836c9a6383e0 | 38 | consoleSerial.write("[INFO] "); |
dan_ackme | 0:836c9a6383e0 | 39 | va_start(args, msg); |
dan_ackme | 0:836c9a6383e0 | 40 | consoleSerial.vprintf(msg, args); |
dan_ackme | 0:836c9a6383e0 | 41 | va_end(args); |
dan_ackme | 0:836c9a6383e0 | 42 | } |
dan_ackme | 0:836c9a6383e0 | 43 | |
dan_ackme | 0:836c9a6383e0 | 44 | /*************************************************************************************************/ |
dan_ackme | 0:836c9a6383e0 | 45 | void logWrite(const void *data, int size) |
dan_ackme | 0:836c9a6383e0 | 46 | { |
dan_ackme | 0:836c9a6383e0 | 47 | consoleSerial.write(data, size); |
dan_ackme | 0:836c9a6383e0 | 48 | } |
dan_ackme | 0:836c9a6383e0 | 49 | |
dan_ackme | 0:836c9a6383e0 | 50 | /*************************************************************************************************/ |
dan_ackme | 0:836c9a6383e0 | 51 | void logInfoWriteStr(const char *msg, const char *s) |
dan_ackme | 0:836c9a6383e0 | 52 | { |
dan_ackme | 0:836c9a6383e0 | 53 | consoleSerial.printf("[INFO] %s", msg); |
dan_ackme | 0:836c9a6383e0 | 54 | consoleSerial.write(s); |
dan_ackme | 0:836c9a6383e0 | 55 | consoleSerial.write("\r\n"); |
dan_ackme | 0:836c9a6383e0 | 56 | } |
dan_ackme | 0:836c9a6383e0 | 57 | |
dan_ackme | 0:836c9a6383e0 | 58 | /*************************************************************************************************/ |
dan_ackme | 0:836c9a6383e0 | 59 | void logError(const char *msg, ...) |
dan_ackme | 0:836c9a6383e0 | 60 | { |
dan_ackme | 0:836c9a6383e0 | 61 | va_list args; |
dan_ackme | 0:836c9a6383e0 | 62 | consoleSerial.write("[ERROR] "); |
dan_ackme | 0:836c9a6383e0 | 63 | va_start(args, msg); |
dan_ackme | 0:836c9a6383e0 | 64 | consoleSerial.vprintf(msg, args); |
dan_ackme | 0:836c9a6383e0 | 65 | va_end(args); |
dan_ackme | 0:836c9a6383e0 | 66 | } |
dan_ackme | 0:836c9a6383e0 | 67 | |
dan_ackme | 0:836c9a6383e0 | 68 | /*************************************************************************************************/ |
dan_ackme | 0:836c9a6383e0 | 69 | void logWiconnectError(WiconnectResult result, const char *msg, ...) |
dan_ackme | 0:836c9a6383e0 | 70 | { |
dan_ackme | 0:836c9a6383e0 | 71 | va_list args; |
dan_ackme | 0:836c9a6383e0 | 72 | consoleSerial.write("[ERROR] "); |
dan_ackme | 0:836c9a6383e0 | 73 | va_start(args, msg); |
dan_ackme | 0:836c9a6383e0 | 74 | consoleSerial.printf("%s, (%d) %s\r\n", msg, result, Wiconnect::getWiconnectResultStr(result)); |
dan_ackme | 0:836c9a6383e0 | 75 | va_end(args); |
dan_ackme | 0:836c9a6383e0 | 76 | } |
dan_ackme | 0:836c9a6383e0 | 77 | |
dan_ackme | 0:836c9a6383e0 | 78 |