diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..3cce948 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "restructuredtext.confPath": "" +} \ No newline at end of file diff --git a/Makefile b/Makefile index c93cce7..d3bb753 100644 --- a/Makefile +++ b/Makefile @@ -15,9 +15,9 @@ all: _all VASQ_DIR := . include make.mk -.PHONY: all _all clean doc $(CLEAN_TARGETS) +.PHONY: all _all clean $(CLEAN_TARGETS) -_all: $(VASQ_SHARED_LIBRARY) $(VASQ_STATIC_LIBRARY) $(TESTS) README.pdf +_all: $(VASQ_SHARED_LIBRARY) $(VASQ_STATIC_LIBRARY) $(TESTS) %_test: tests/test_%.o $(VASQ_STATIC_LIBRARY) $(CC) -o $@ $^ @@ -25,8 +25,6 @@ _all: $(VASQ_SHARED_LIBRARY) $(VASQ_STATIC_LIBRARY) $(TESTS) README.pdf tests/test_%.o: tests/test_%.c $(VASQ_HEADER_FILES) $(CC) $(CFLAGS) -I$(VASQ_INCLUDE_DIR) -c $< -o $@ -doc: README.pdf - README.pdf: README.rst rst2pdf $< -o $@ diff --git a/README.rst b/README.rst index 4f28a44..04b5edd 100644 --- a/README.rst +++ b/README.rst @@ -4,7 +4,7 @@ Vanilla Squad :Author: Daniel Walker -Version 4.2.0 was released on May 24, 2021. +Version 4.3.0 was released on June 18, 2021. Overview ======== @@ -154,8 +154,8 @@ Building Vanilla Squad Shared and static libraries are built using make. Adding "debug=yes" to the make invocation will disable optimization and build the libraries with debugging symbols. -The Makefile contains a phony target, **doc**, which creates a PDF from README.rst. It requires the -installation of rst2pdf. +The Makefile also contains the target README.pdf which is created from README.rst. The rst2pdf package is +required. You can also include Vanilla Squad in a larger project by including make.mk. Before doing so, however, the **VASQ_DIR** variable must be set to the location of the Vanilla Squad directory. make.mk will also add a diff --git a/changelog b/changelog index 7c37b36..f09e14b 100644 --- a/changelog +++ b/changelog @@ -1,3 +1,8 @@ +4.3.0: + - Added the functions vasqLoggerFd and vasqLogLevel. + - Added the VASQ_LL_LEVEL_CHANGE macro in config.h. + - Removed the phony target "doc" from the Makefile. + 4.2.0: - vasqLoggerCreate now dups the file descriptor and sets FD_CLOEXEC on it. diff --git a/include/vasq/config.h b/include/vasq/config.h index dcee9c5..d1f872c 100644 --- a/include/vasq/config.h +++ b/include/vasq/config.h @@ -22,4 +22,9 @@ */ #define VASQ_LL_PROCESS VASQ_LL_DEBUG +/* + The log level which displays the setting of a logger's log level. +*/ +#define VASQ_LL_LEVEL_CHANGE VASQ_LL_DEBUG + #endif // VANILLA_SQUAD_CONFIG_H diff --git a/include/vasq/definitions.h b/include/vasq/definitions.h index ba0d740..15aafc8 100644 --- a/include/vasq/definitions.h +++ b/include/vasq/definitions.h @@ -24,6 +24,6 @@ enum vasqRetValue { VASQ_RET_UNUSED, }; -#define VASQ_VERSION "4.2.0" +#define VASQ_VERSION "4.3.0" #endif // VANILLA_SQUAD_DEFINITIONS_H diff --git a/include/vasq/logger.h b/include/vasq/logger.h index 7f94078..1ec2aac 100644 --- a/include/vasq/logger.h +++ b/include/vasq/logger.h @@ -49,9 +49,15 @@ vasqLoggerCreate(int fd, vasqLogLevel_t level, const char *format, vasqLoggerDat void vasqLoggerFree(vasqLogger *logger); +int +vasqLoggerFd(const vasqLogger *logger); + bool vasqSetLoggerFormat(vasqLogger *logger, const char *format); +vasqLogLevel_t +vasqLogLevel(const vasqLogger *logger); + void vasqSetLogLevel(vasqLogger *logger, vasqLogLevel_t level); diff --git a/source/logger.c b/source/logger.c index 0687a41..5a11bb3 100644 --- a/source/logger.c +++ b/source/logger.c @@ -132,10 +132,10 @@ vasqLoggerCreate(int fd, vasqLogLevel_t level, const char *format, vasqLoggerDat } (*logger)->fd = new_fd; - (*logger)->level = level; (*logger)->format = format; (*logger)->processor = processor; (*logger)->user_data = user_data; + vasqSetLogLevel(*logger, level); flags = fcntl(new_fd, F_GETFD); if (flags == -1 || fcntl(new_fd, F_SETFD, flags | FD_CLOEXEC) == -1) { @@ -156,6 +156,12 @@ vasqLoggerFree(vasqLogger *logger) } } +int +vasqLoggerFd(const vasqLogger *logger) +{ + return logger? logger->fd : -1; +} + bool vasqSetLoggerFormat(vasqLogger *logger, const char *format) { @@ -168,12 +174,18 @@ vasqSetLoggerFormat(vasqLogger *logger, const char *format) } } +vasqLogLevel_t +vasqLogLevel(const vasqLogger *logger) +{ + return logger? logger->level : VASQ_LL_NONE; +} + void vasqSetLogLevel(vasqLogger *logger, vasqLogLevel_t level) { if (logger) { logger->level = level; - VASQ_DEBUG(logger, "Log level set to %s", logLevelName(level)); + vasqLogStatement(logger, VASQ_LL_LEVEL_CHANGE, VASQ_CONTEXT_PARAMS, "Log level set to %s", logLevelName(level)); } }