EDGESEC
0.1.0-alpha.0+sha.ca29a8277b72f80785649ea9ef9cd7edf642d939
Secure router - reference implementation
|
#include <stdarg.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <inttypes.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <syslog.h>
#include <time.h>
#include <unistd.h>
#include "log.h"
Macros | |
#define | _POSIX_C_SOURCE 200112L |
#define | PRINT_COLOR(stream, time, color, name, err, file, line) |
#define | PRINT_NO_COLOR(stream, time, color, name, err, file, line) fprintf(stream, "%s %-5s%s %s:%d: ", time, name, err, file, line) |
Functions | |
void | log_set_lock (log_lock_fn fn) |
void | log_set_level (uint8_t level) |
void | log_set_quiet (bool enable) |
void | log_set_meta (bool enable) |
void | log_set_color (bool enable) |
int | log_open_file (char *path) |
void | log_close_file (void) |
bool | log_check_level (uint8_t level, bool ignore_level) |
int | get_error_text (char *buf, int err) |
Get the error text object. More... | |
void | print_to (uint8_t level, const char *file, uint32_t line, int err, const char *time_string, const char *err_text_buf, const char *format, va_list args) |
void | log_msg (uint8_t level, const char *file, uint32_t line, bool flush_std, bool ignore_level, int err, const char *format, va_list args) |
void | log_levels (uint8_t level, const char *file, uint32_t line, const char *format,...) |
void | log_errno_error (uint8_t level, const char *file, uint32_t line, const char *format,...) |
void | log_error_exit (uint8_t level, const char *file, uint32_t line, const char *format,...) |
void | log_error_exit_proc (uint8_t level, const char *file, uint32_t line, const char *format,...) |
size_t | printf_hex (char *buf, size_t buf_size, const uint8_t *data, size_t len, bool uppercase) |
Prints the data in data to buf as hex. More... | |
#define _POSIX_C_SOURCE 200112L |
#define PRINT_COLOR | ( | stream, | |
time, | |||
color, | |||
name, | |||
err, | |||
file, | |||
line | |||
) |
#define PRINT_NO_COLOR | ( | stream, | |
time, | |||
color, | |||
name, | |||
err, | |||
file, | |||
line | |||
) | fprintf(stream, "%s %-5s%s %s:%d: ", time, name, err, file, line) |
int get_error_text | ( | char * | buf, |
int | err | ||
) |
Get the error text object.
[out] | buf | String buffer of at least 30 chars |
err | errno value passed to strerror() |
buf
, or 0 if buf is empty.Warning, this function is non-threadsafe, as stderror() is not guaranteed to be threadsafe. Please make sure to uses mutxes/locks before calling this function.
bool log_check_level | ( | uint8_t | level, |
bool | ignore_level | ||
) |
void log_close_file | ( | void | ) |
void log_errno_error | ( | uint8_t | level, |
const char * | file, | ||
uint32_t | line, | ||
const char * | format, | ||
... | |||
) |
void log_error_exit | ( | uint8_t | level, |
const char * | file, | ||
uint32_t | line, | ||
const char * | format, | ||
... | |||
) |
void log_error_exit_proc | ( | uint8_t | level, |
const char * | file, | ||
uint32_t | line, | ||
const char * | format, | ||
... | |||
) |
void log_levels | ( | uint8_t | level, |
const char * | file, | ||
uint32_t | line, | ||
const char * | format, | ||
... | |||
) |
void log_msg | ( | uint8_t | level, |
const char * | file, | ||
uint32_t | line, | ||
bool | flush_std, | ||
bool | ignore_level, | ||
int | err, | ||
const char * | format, | ||
va_list | args | ||
) |
int log_open_file | ( | char * | path | ) |
void log_set_color | ( | bool | enable | ) |
void log_set_level | ( | uint8_t | level | ) |
void log_set_lock | ( | log_lock_fn | fn | ) |
void log_set_meta | ( | bool | enable | ) |
void log_set_quiet | ( | bool | enable | ) |
void print_to | ( | uint8_t | level, |
const char * | file, | ||
uint32_t | line, | ||
int | err, | ||
const char * | time_string, | ||
const char * | err_text_buf, | ||
const char * | format, | ||
va_list | args | ||
) |
size_t printf_hex | ( | char * | buf, |
size_t | buf_size, | ||
const uint8_t * | data, | ||
size_t | len, | ||
bool | uppercase | ||
) |
Prints the data in data
to buf
as hex.
Prints the data in data
to buf
as hex.
[out] | buf | The output string buffer. |
buf_size | The size of the output buffer, buf . As this will NUL terminated, make sure that this is an odd number, otherwise you may cut a hex-byte in half. | |
[in] | data | The input data to print to buf . |
len | The length of data . | |
uppercase | If false , print hex in lowercase. If true , print hex in uppercase. |
buf
without truncation. This excludes the NUL
-terminator.src/utils/common.c
, see https://w1.fi/cgit/hostap/tree/src/utils/common.c?h=hostap_2_10#n317, except with additional NULL pointer checking. bool color |
uint8_t level |
static void lock | ( | void | ) |
FILE* logfp |
bool meta |
bool quiet |