forked from PSU-AVT/QuadLLFC
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlogging.c
More file actions
38 lines (30 loc) · 789 Bytes
/
logging.c
File metadata and controls
38 lines (30 loc) · 789 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
36
37
38
/*
* Copyright (c) 2011 Gregory Haynes <greg@greghaynes.net>
*
* Licensed under the BSD license. See LICENSE for more information.
*/
#include "logging.h"
#include "commands.h"
#include <string.h>
static LOGGING_LEVEL LOG_LEVEL = 0;
void logging_send_string(LOGGING_LEVEL level, const char *str) {
uint16_t len = 0;
while(str[++len]);
logging_send_buff(level, (const unsigned char*)str, len);
}
void logging_send_buff(LOGGING_LEVEL level, const unsigned char *buff, uint16_t buff_len) {
if(level < LOG_LEVEL)
return;
uint8_t command_id;
switch(level) {
case LOGGING_DEBUG:
command_id = COMMAND_DEBUG;
break;
default:
command_id = COMMAND_ERROR;
}
command_send(command_id, buff, buff_len);
}
void logging_set_level(LOGGING_LEVEL level) {
LOG_LEVEL = level;
}