Commit 4bf087c5 authored by Dominik Charousset's avatar Dominik Charousset Committed by Dominik Charousset

Remove magic numbers from CMake

parent c848d5f6
......@@ -367,23 +367,11 @@ endif()
# setup logging #
################################################################################
# make sure log level is defined and all-uppercase
if(NOT CAF_LOG_LEVEL)
set(CAF_LOG_LEVEL "QUIET")
endif()
# set human-readable representation for log level
if(CAF_LOG_LEVEL STREQUAL "ERROR")
set(CAF_LOG_LEVEL_INT 3)
elseif(CAF_LOG_LEVEL STREQUAL "WARNING")
set(CAF_LOG_LEVEL_INT 6)
elseif(CAF_LOG_LEVEL STREQUAL "INFO")
set(CAF_LOG_LEVEL_INT 9)
elseif(CAF_LOG_LEVEL STREQUAL "DEBUG")
set(CAF_LOG_LEVEL_INT 12)
elseif(CAF_LOG_LEVEL STREQUAL "TRACE")
set(CAF_LOG_LEVEL_INT 15)
else()
set(CAF_LOG_LEVEL_INT 0)
string(TOUPPER "${CAF_LOG_LEVEL}" CAF_LOG_LEVEL)
endif()
################################################################################
......@@ -713,7 +701,7 @@ if(NOT CAF_NO_SUMMARY)
"\nBuild static only: ${CAF_BUILD_STATIC_ONLY}"
"\nBuild static runtime: ${CAF_BUILD_STATIC_RUNTIME}"
"\nRuntime checks: ${CAF_ENABLE_RUNTIME_CHECKS}"
"\nLog level: ${LOG_LEVEL_STR}"
"\nLog level: ${CAF_LOG_LEVEL}"
"\nWith mem. mgmt.: ${CAF_BUILD_MEM_MANAGEMENT}"
"\nWith exceptions: ${CAF_BUILD_WITH_EXCEPTIONS}"
"\n"
......
......@@ -17,7 +17,7 @@ releaseBuildFlags = defaultBuildFlags + [
debugBuildFlags = defaultBuildFlags + [
'CAF_ENABLE_RUNTIME_CHECKS:BOOL=yes',
'CAF_ENABLE_ADDRESS_SANITIZER:BOOL=yes',
'CAF_LOG_LEVEL:STRING=4',
'CAF_LOG_LEVEL:STRING=TRACE',
]
// Our build matrix. The keys are the operating system labels and the values
......
......@@ -19,9 +19,11 @@
#pragma once
#include "caf/detail/log_level.hpp"
// this header is auto-generated by CMake
#define CAF_LOG_LEVEL @CAF_LOG_LEVEL_INT@
#define CAF_LOG_LEVEL CAF_LOG_LEVEL_@CAF_LOG_LEVEL@
#cmakedefine CAF_NO_MEM_MANAGEMENT
......
......@@ -282,8 +282,7 @@ while [ $# -ne 0 ]; do
append_cache_entry CAF_IOS_DEPLOYMENT_TARGET STRING "$optarg"
;;
--with-log-level=*)
level=`echo "$optarg" | tr '[:lower:]' '[:upper:]'`
append_cache_entry CAF_LOG_LEVEL STRING "$level"
append_cache_entry CAF_LOG_LEVEL STRING "$optarg"
;;
--with-clang=*)
clang="$optarg"
......
/******************************************************************************
* ____ _ _____ *
* / ___| / \ | ___| C++ *
* | | / _ \ | |_ Actor *
* | |___ / ___ \| _| Framework *
* \____/_/ \_|_| *
* *
* Copyright 2011-2018 Dominik Charousset *
* *
* Distributed under the terms and conditions of the BSD 3-Clause License or *
* (at your option) under the terms and conditions of the Boost Software *
* License 1.0. See accompanying files LICENSE and LICENSE_ALTERNATIVE. *
* *
* If you did not receive a copy of the license files, see *
* http://opensource.org/licenses/BSD-3-Clause and *
* http://www.boost.org/LICENSE_1_0.txt. *
******************************************************************************/
#pragma once
/// Integer value for the QUIET log level.
#define CAF_LOG_LEVEL_QUIET 0
/// Integer value for the ERROR log level.
#define CAF_LOG_LEVEL_ERROR 3
/// Integer value for the WARNING log level.
#define CAF_LOG_LEVEL_WARNING 6
/// Integer value for the INFO log level.
#define CAF_LOG_LEVEL_INFO 9
/// Integer value for the DEBUG log level.
#define CAF_LOG_LEVEL_DEBUG 12
/// Integer value for the TRACE log level.
#define CAF_LOG_LEVEL_TRACE 15
......@@ -390,24 +390,6 @@ bool operator==(const logger::field& x, const logger::field& y);
// -- macro constants ----------------------------------------------------------
/// Integer value for the QUIET log level.
#define CAF_LOG_LEVEL_QUIET 0
/// Integer value for the ERROR log level.
#define CAF_LOG_LEVEL_ERROR 3
/// Integer value for the WARNING log level.
#define CAF_LOG_LEVEL_WARNING 6
/// Integer value for the INFO log level.
#define CAF_LOG_LEVEL_INFO 9
/// Integer value for the DEBUG log level.
#define CAF_LOG_LEVEL_DEBUG 12
/// Integer value for the TRACE log level.
#define CAF_LOG_LEVEL_TRACE 15
/// Expands to a no-op.
#define CAF_VOID_STMT static_cast<void>(0)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment