-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlogger_api.h
More file actions
71 lines (64 loc) · 1.46 KB
/
logger_api.h
File metadata and controls
71 lines (64 loc) · 1.46 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#ifndef LOGGER_API_H
#define LOGGER_API_H
#include <stdint.h>
#include <stdio.h>
#include <time.h>
#include <limits.h>
#define TS_BUF_LENGTH 30
#define HDR_BUF_LENGTH 1024
#define HDR_VERSION_LENGTH 25
#define HDR_FIELDS_LENGTH 100
#define HDR_OPTION_LENGTH 100
#define CRLF "\r\n"
#define SPACE " "
#define HYPHEN "-"
#define DATE_OPTION 0x01
#define SOFTWARE_OPTION 0x02
#define ESC_COLOR_RED "\033[1;31m"
#define ESC_COLOR_YELLOW "\033[1;33m"
#define ESC_COLOR_GREEN "\033[1;32m"
#define ESC_COLOR_RESET "\033[1;0m"
typedef enum
{
GET,
UNSUPPORTED,
METHODS_COUNT
} Method;
typedef enum
{
DATE = 0,
TIME,
C_IP,
CS_METHOD,
CS_URI,
S_IP,
SC_STATUS,
FIELDS_COUNT
} field_t;
typedef struct
{
struct tm date;
struct tm time;
char* c_ip;
char cs_uri[PATH_MAX];
char* s_ip;
Method cs_method;
uint16_t sc_status;
} log_entry_config_t;
typedef enum
{
NONE,
ERROR,
WARN,
INFO,
COUNT_LOG_LVL
} log_lvl_t;
void msg_log(FILE* fp, char* msg, uint8_t options);
char* get_method_name(Method m, char** methods);
char* get_msg_log_field_name(field_t field_type, char** fields);
void construct_msg_log_header(char* header_buf, size_t header_size,
float version, char** fields, uint8_t options);
int serialize_msg_log_entry(char* entry_buf, size_t entry_size,
log_entry_config_t* msg_log_entry);
void print_debug(log_lvl_t log_lvl, char* fmt, ...);
#endif