Skip to content

Commit

Permalink
added the vasqLoggerFd and vasqLogLevel functions; releasing 4.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
nickeldan committed Jun 18, 2021
1 parent 277ad22 commit a9533f3
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 10 deletions.
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"restructuredtext.confPath": ""
}
6 changes: 2 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,16 @@ 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 $@ $^

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 $@

Expand Down
6 changes: 3 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
========
Expand Down Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions changelog
Original file line number Diff line number Diff line change
@@ -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.

Expand Down
5 changes: 5 additions & 0 deletions include/vasq/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion include/vasq/definitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 6 additions & 0 deletions include/vasq/logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
16 changes: 14 additions & 2 deletions source/logger.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -156,6 +156,12 @@ vasqLoggerFree(vasqLogger *logger)
}
}

int
vasqLoggerFd(const vasqLogger *logger)
{
return logger? logger->fd : -1;
}

bool
vasqSetLoggerFormat(vasqLogger *logger, const char *format)
{
Expand All @@ -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));
}
}

Expand Down

0 comments on commit a9533f3

Please sign in to comment.