diff --git a/Makefile b/Makefile index 15eefc9..0aed059 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ CFLAGS=-Wall -DPACKAGE_VERSION=\"0.0\" %.o: %.c $(CC) $(CFLAGS) -o $@ -c $^ -v5le: main.o v5x_data.o lapv5.o +v5le: main.o logging.o v5x_data.o lapv5.o $(CC) -o $@ $^ $(LIBS) clean: diff --git a/logging.c b/logging.c new file mode 100644 index 0000000..7c7a69f --- /dev/null +++ b/logging.c @@ -0,0 +1,30 @@ + +#include +#include "logging.h" + +static const struct log_info_cat log_categories[] = { + [DV5] = { + .name = "DV5", + .description = "V5 protocol", + .color = "\033[1;33m", + .enabled = 1, .loglevel = LOGL_DEBUG, + }, + [DV5CTRL] = { + .name = "DV5CTRL", + .description = "V5 control protocol", + .color = "\033[0;35m", + .enabled = 1, .loglevel = LOGL_DEBUG, + }, + [DV5EF] = { + .name = "DV5EF", + .description = "V5 envelop frame", + .color = "\033[1;34m", + .enabled = 1, .loglevel = LOGL_DEBUG, + }, +}; + +const struct log_info log_info = { + .cat = log_categories, + .num_cat = ARRAY_SIZE(log_categories), +}; + diff --git a/logging.h b/logging.h new file mode 100644 index 0000000..c9f607b --- /dev/null +++ b/logging.h @@ -0,0 +1,11 @@ +#pragma once + +#include + +enum { + DV5, + DV5CTRL, + DV5EF, +}; + +extern const struct log_info log_info; diff --git a/main.c b/main.c index aa3baac..b7b5d8b 100644 --- a/main.c +++ b/main.c @@ -34,7 +34,6 @@ #include #include #include -#include #include #include @@ -49,6 +48,7 @@ #include +#include "logging.h" #define _GNU_SOURCE #include @@ -250,14 +250,6 @@ static struct vty_app_info vty_info = { .is_config_node = v5le_vty_is_config_node, }; -static const struct log_info_cat log_categories[] = { -}; - -const struct log_info log_info = { - .cat = log_categories, - .num_cat = ARRAY_SIZE(log_categories), -}; - int main(int argc, char **argv) { unsigned int flags;