Skip to content

Commit

Permalink
Make sure logger levels stay in sync across files
Browse files Browse the repository at this point in the history
  • Loading branch information
nurupo committed Oct 7, 2018
1 parent f5afc52 commit 56432a4
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .travis/cmake-linux
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ travis_script() {
# Use () to run in a separate process so the exports are local.
(run_static_analysis)

other/analysis/check_logger_levels

cmake -B_build -H. \
-DCMAKE_C_FLAGS="$C_FLAGS" \
-DCMAKE_CXX_FLAGS="$CXX_FLAGS" \
Expand Down
18 changes: 18 additions & 0 deletions other/analysis/check_logger_levels
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/sh

# Make sure that logger levels in toxcore/logger.h, CMakeLists.txt and
# configure.ac stay in sync.

set -ex

TMP_DIR="$(mktemp -d)"

# ^\s+LOGGER_LEVEL_(\w+),?$
sed -n 's/^\s\+LOGGER_LEVEL_\(\w\+\),\?$/\1/p' toxcore/logger.h > "${TMP_DIR}/logger.h"
# ^.*\$\{MIN_LOGGER_LEVEL\}" STREQUAL "(\w+)".*$
sed -n 's/^.*\${MIN_LOGGER_LEVEL}\" STREQUAL \"\(\w\+\)\".*$/\1/p' CMakeLists.txt > "${TMP_DIR}/CMakeLists.txt"
# ^.*LOGGER_LEVEL_(\w+).*$
sed -n 's/^.*LOGGER_LEVEL_\(\w\+\).*$/\1/p' configure.ac > "${TMP_DIR}/configure.ac"

diff -u "${TMP_DIR}/CMakeLists.txt" "${TMP_DIR}/logger.h"
diff -u "${TMP_DIR}/configure.ac" "${TMP_DIR}/logger.h"
1 change: 1 addition & 0 deletions toxcore/logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#define MIN_LOGGER_LEVEL LOGGER_LEVEL_INFO
#endif

// NOTE: Don't forget to update build system files after modifying the enum.
typedef enum Logger_Level {
LOGGER_LEVEL_TRACE,
LOGGER_LEVEL_DEBUG,
Expand Down

0 comments on commit 56432a4

Please sign in to comment.