-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLogSerial.cpp
More file actions
35 lines (30 loc) · 888 Bytes
/
LogSerial.cpp
File metadata and controls
35 lines (30 loc) · 888 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/*
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
*/
#include "Arduino.h"
#include "LogSerial.h"
#define LOGSERIAL_BUFSIZE 256
void LogSerial_LogImpl(int loglevel, const char* msg, ...)
{
if (loglevel <= LOGSERIAL_LOGGING_LEVEL)
{
char buff[LOGSERIAL_BUFSIZE];
va_list argptr;
va_start(argptr, msg);
int bytesout = vsnprintf(buff, LOGSERIAL_BUFSIZE-1, msg, argptr);
va_end(argptr);
buff[LOGSERIAL_BUFSIZE-1] = '\0';
if (bytesout < LOGSERIAL_BUFSIZE-1)
{
Serial.println(buff);
}
else
{
Serial.print(buff);
Serial.println("...");
}
}
}