0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-15 14:31:11 +01:00

configure.ac/ircd: Add granular configure-time log level control.

This commit is contained in:
Jason Volk 2018-05-21 16:55:10 -07:00
parent fcb1df34da
commit a2b80db1ad
2 changed files with 280 additions and 82 deletions

View file

@ -204,6 +204,51 @@ AC_ARG_ENABLE(optimize, AC_HELP_STRING([--enable-optimize], [Enable optimization
AM_CONDITIONAL([OPTIMIZE], [[[[ "$OPTIMIZE" = "1" ]]]]) AM_CONDITIONAL([OPTIMIZE], [[[[ "$OPTIMIZE" = "1" ]]]])
dnl
dnl Explicit log level
dnl
AC_MSG_CHECKING(whether to explicitly set the logging level ceiling)
AC_ARG_WITH(log-level, AC_HELP_STRING([--with-log-level[[[=INFO]]]], [Explicitly set the log level ceiling]),
[
AC_MSG_RESULT([yes, enabling log level $withval and below])
level=4
if [[ $withval = "DEBUG" ]]; then
level=7
elif [[ $withval = "DWARNING" ]]; then
level=6
elif [[ $withval = "DERROR" ]]; then
level=5
elif [[ $withval = "INFO" ]]; then
level=4
elif [[ $withval = "NOTICE" ]]; then
level=3
elif [[ $withval = "WARNING" ]]; then
level=2
elif [[ $withval = "ERROR" ]]; then
level=1
elif [[ $withval = "CRITICAL" ]]; then
level=0
elif [[ $withval = "-1" ]]; then
level=-1
fi
AC_SUBST(LOG_LEVEL, $level)
RB_DEFINE_UNQUOTED([LOG_LEVEL], [$level], [Log messages for user configured level and below.])
], [
AM_COND_IF(DEBUG,
[
AC_MSG_RESULT([no, but debug mode enables all log levels through DEBUG])
AC_SUBST(LOG_LEVEL, 7)
RB_DEFINE_UNQUOTED([LOG_LEVEL], [7], [Log message level default for DEBUG mode])
], [
AC_MSG_RESULT([no])
AC_SUBST(LOG_LEVEL, 4)
RB_DEFINE_UNQUOTED([LOG_LEVEL], [4], [Log message level default for release mode])
])
])
dnl dnl
dnl Profiling mode dnl Profiling mode
@ -1492,6 +1537,7 @@ echo "Precompiled headers ............... $build_pch"
echo "Developer debug ................... $debug" echo "Developer debug ................... $debug"
echo "Developer assert .................. $assert" echo "Developer assert .................. $assert"
echo "Optimized build ................... $optimize" echo "Optimized build ................... $optimize"
echo "Logging level ..................... $LOG_LEVEL"
echo "Installing into ................... $prefix" echo "Installing into ................... $prefix"
echo echo
echo "* Ready to build $PACKAGE_NAME" echo "* Ready to build $PACKAGE_NAME"

View file

@ -95,19 +95,51 @@ struct ircd::log::log
public: public:
template<class... args> void operator()(const facility &, const char *const &fmt, args&&...); template<class... args> void operator()(const facility &, const char *const &fmt, args&&...);
#if RB_LOG_LEVEL >= 0
template<class... args> void critical(const char *const &fmt, args&&...); template<class... args> void critical(const char *const &fmt, args&&...);
template<class... args> void error(const char *const &fmt, args&&...); #else // Required for DCE in gcc 6.3.0 20170519
template<class... args> void warning(const char *const &fmt, args&&...); void critical(const char *const &fmt, ...);
template<class... args> void notice(const char *const &fmt, args&&...); #endif
template<class... args> void info(const char *const &fmt, args&&...);
#ifdef RB_DEBUG #if RB_LOG_LEVEL >= 1
template<class... args> void error(const char *const &fmt, args&&...);
#else // Required for DCE in gcc 6.3.0 20170519
void error(const char *const &fmt, ...);
#endif
#if RB_LOG_LEVEL >= 2
template<class... args> void warning(const char *const &fmt, args&&...);
#else // Required for DCE in gcc 6.3.0 20170519
void warning(const char *const &fmt, ...);
#endif
#if RB_LOG_LEVEL >= 3
template<class... args> void notice(const char *const &fmt, args&&...);
#else // Required for DCE in gcc 6.3.0 20170519
void notice(const char *const &fmt, ...);
#endif
#if RB_LOG_LEVEL >= 4
template<class... args> void info(const char *const &fmt, args&&...);
#else // Required for DCE in gcc 6.3.0 20170519
void info(const char *const &fmt, ...);
#endif
#if RB_LOG_LEVEL >= 5
template<class... args> void derror(const char *const &fmt, args&&...); template<class... args> void derror(const char *const &fmt, args&&...);
template<class... args> void dwarning(const char *const &fmt, args&&...);
template<class... args> void debug(const char *const &fmt, args&&...);
#else // Required for DCE in gcc 6.3.0 20170519 #else // Required for DCE in gcc 6.3.0 20170519
void derror(const char *const &fmt, ...); void derror(const char *const &fmt, ...);
#endif
#if RB_LOG_LEVEL >= 6
template<class... args> void dwarning(const char *const &fmt, args&&...);
#else // Required for DCE in gcc 6.3.0 20170519
void dwarning(const char *const &fmt, ...); void dwarning(const char *const &fmt, ...);
#endif
#if RB_LOG_LEVEL >= 7
template<class... args> void debug(const char *const &fmt, args&&...);
#else // Required for DCE in gcc 6.3.0 20170519
void debug(const char *const &fmt, ...); void debug(const char *const &fmt, ...);
#endif #endif
@ -144,7 +176,7 @@ struct ircd::log::console_quiet
~console_quiet(); ~console_quiet();
}; };
#ifdef RB_DEBUG #if RB_LOG_LEVEL >= 7
struct ircd::log::debug struct ircd::log::debug
{ {
template<class... args> template<class... args>
@ -174,37 +206,7 @@ struct ircd::log::debug
}; };
#endif #endif
struct ircd::log::info #if RB_LOG_LEVEL >= 6
{
template<class... args>
info(const log &log, const char *const &fmt, args&&... a)
{
vlog(log, facility::INFO, fmt, va_rtti{std::forward<args>(a)...});
}
template<class... args>
info(const char *const &fmt, args&&... a)
{
vlog(general, facility::INFO, fmt, va_rtti{std::forward<args>(a)...});
}
};
struct ircd::log::notice
{
template<class... args>
notice(const log &log, const char *const &fmt, args&&... a)
{
vlog(log, facility::NOTICE, fmt, va_rtti{std::forward<args>(a)...});
}
template<class... args>
notice(const char *const &fmt, args&&... a)
{
vlog(general, facility::NOTICE, fmt, va_rtti{std::forward<args>(a)...});
}
};
#ifdef RB_DEBUG
struct ircd::log::dwarning struct ircd::log::dwarning
{ {
template<class... args> template<class... args>
@ -234,22 +236,7 @@ struct ircd::log::dwarning
}; };
#endif #endif
struct ircd::log::warning #if RB_LOG_LEVEL >= 5
{
template<class... args>
warning(const log &log, const char *const &fmt, args&&... a)
{
vlog(log, facility::WARNING, fmt, va_rtti{std::forward<args>(a)...});
}
template<class... args>
warning(const char *const &fmt, args&&... a)
{
vlog(general, facility::WARNING, fmt, va_rtti{std::forward<args>(a)...});
}
};
#ifdef RB_DEBUG
struct ircd::log::derror struct ircd::log::derror
{ {
template<class... args> template<class... args>
@ -279,6 +266,97 @@ struct ircd::log::derror
}; };
#endif #endif
#if RB_LOG_LEVEL >= 4
struct ircd::log::info
{
template<class... args>
info(const log &log, const char *const &fmt, args&&... a)
{
vlog(log, facility::INFO, fmt, va_rtti{std::forward<args>(a)...});
}
template<class... args>
info(const char *const &fmt, args&&... a)
{
vlog(general, facility::INFO, fmt, va_rtti{std::forward<args>(a)...});
}
};
#else
struct ircd::log::info
{
info(const log &, const char *const &, ...)
{
// Required in gcc 6.3.0 20170519, template param packs are not DCE'ed
}
info(const char *const &, ...)
{
// Required in gcc 6.3.0 20170519, template param packs are not DCE'ed
}
};
#endif
#if RB_LOG_LEVEL >= 3
struct ircd::log::notice
{
template<class... args>
notice(const log &log, const char *const &fmt, args&&... a)
{
vlog(log, facility::NOTICE, fmt, va_rtti{std::forward<args>(a)...});
}
template<class... args>
notice(const char *const &fmt, args&&... a)
{
vlog(general, facility::NOTICE, fmt, va_rtti{std::forward<args>(a)...});
}
};
#else
struct ircd::log::notice
{
notice(const log &, const char *const &, ...)
{
// Required in gcc 6.3.0 20170519, template param packs are not DCE'ed
}
notice(const char *const &, ...)
{
// Required in gcc 6.3.0 20170519, template param packs are not DCE'ed
}
};
#endif
#if RB_LOG_LEVEL >= 2
struct ircd::log::warning
{
template<class... args>
warning(const log &log, const char *const &fmt, args&&... a)
{
vlog(log, facility::WARNING, fmt, va_rtti{std::forward<args>(a)...});
}
template<class... args>
warning(const char *const &fmt, args&&... a)
{
vlog(general, facility::WARNING, fmt, va_rtti{std::forward<args>(a)...});
}
};
#else
struct ircd::log::warning
{
warning(const log &, const char *const &, ...)
{
// Required in gcc 6.3.0 20170519, template param packs are not DCE'ed
}
warning(const char *const &, ...)
{
// Required in gcc 6.3.0 20170519, template param packs are not DCE'ed
}
};
#endif
#if RB_LOG_LEVEL >= 1
struct ircd::log::error struct ircd::log::error
{ {
template<class... args> template<class... args>
@ -293,7 +371,22 @@ struct ircd::log::error
vlog(general, facility::ERROR, fmt, va_rtti{std::forward<args>(a)...}); vlog(general, facility::ERROR, fmt, va_rtti{std::forward<args>(a)...});
} }
}; };
#else
struct ircd::log::error
{
error(const log &, const char *const &, ...)
{
// Required in gcc 6.3.0 20170519, template param packs are not DCE'ed
}
error(const char *const &, ...)
{
// Required in gcc 6.3.0 20170519, template param packs are not DCE'ed
}
};
#endif
#if RB_LOG_LEVEL >= 0
struct ircd::log::critical struct ircd::log::critical
{ {
template<class... args> template<class... args>
@ -308,8 +401,22 @@ struct ircd::log::critical
vlog(general, facility::CRITICAL, fmt, va_rtti{std::forward<args>(a)...}); vlog(general, facility::CRITICAL, fmt, va_rtti{std::forward<args>(a)...});
} }
}; };
#else
struct ircd::log::critical
{
critical(const log &, const char *const &, ...)
{
// Required in gcc 6.3.0 20170519, template param packs are not DCE'ed
}
#ifdef RB_DEBUG critical(const char *const &, ...)
{
// Required in gcc 6.3.0 20170519, template param packs are not DCE'ed
}
};
#endif
#if RB_LOG_LEVEL >= 7
template<class... args> template<class... args>
void void
ircd::log::log::debug(const char *const &fmt, ircd::log::log::debug(const char *const &fmt,
@ -326,23 +433,7 @@ ircd::log::log::debug(const char *const &fmt,
} }
#endif #endif
template<class... args> #if RB_LOG_LEVEL >= 6
void
ircd::log::log::info(const char *const &fmt,
args&&... a)
{
operator()(facility::INFO, fmt, va_rtti{std::forward<args>(a)...});
}
template<class... args>
void
ircd::log::log::notice(const char *const &fmt,
args&&... a)
{
operator()(facility::NOTICE, fmt, va_rtti{std::forward<args>(a)...});
}
#ifdef RB_DEBUG
template<class... args> template<class... args>
void void
ircd::log::log::dwarning(const char *const &fmt, ircd::log::log::dwarning(const char *const &fmt,
@ -359,15 +450,7 @@ ircd::log::log::dwarning(const char *const &fmt,
} }
#endif #endif
template<class... args> #if RB_LOG_LEVEL >= 5
void
ircd::log::log::warning(const char *const &fmt,
args&&... a)
{
operator()(facility::WARNING, fmt, va_rtti{std::forward<args>(a)...});
}
#ifdef RB_DEBUG
template<class... args> template<class... args>
void void
ircd::log::log::derror(const char *const &fmt, ircd::log::log::derror(const char *const &fmt,
@ -384,6 +467,58 @@ ircd::log::log::derror(const char *const &fmt,
} }
#endif #endif
#if RB_LOG_LEVEL >= 4
template<class... args>
void
ircd::log::log::info(const char *const &fmt,
args&&... a)
{
operator()(facility::INFO, fmt, va_rtti{std::forward<args>(a)...});
}
#else
inline void
ircd::log::log::info(const char *const &fmt,
...)
{
// Required in gcc 6.3.0 20170519, template param packs are not DCE'ed
}
#endif
#if RB_LOG_LEVEL >= 3
template<class... args>
void
ircd::log::log::notice(const char *const &fmt,
args&&... a)
{
operator()(facility::NOTICE, fmt, va_rtti{std::forward<args>(a)...});
}
#else
inline void
ircd::log::log::notice(const char *const &fmt,
...)
{
// Required in gcc 6.3.0 20170519, template param packs are not DCE'ed
}
#endif
#if RB_LOG_LEVEL >= 2
template<class... args>
void
ircd::log::log::warning(const char *const &fmt,
args&&... a)
{
operator()(facility::WARNING, fmt, va_rtti{std::forward<args>(a)...});
}
#else
inline void
ircd::log::log::warning(const char *const &fmt,
...)
{
// Required in gcc 6.3.0 20170519, template param packs are not DCE'ed
}
#endif
#if RB_LOG_LEVEL >= 1
template<class... args> template<class... args>
void void
ircd::log::log::error(const char *const &fmt, ircd::log::log::error(const char *const &fmt,
@ -391,7 +526,16 @@ ircd::log::log::error(const char *const &fmt,
{ {
operator()(facility::ERROR, fmt, va_rtti{std::forward<args>(a)...}); operator()(facility::ERROR, fmt, va_rtti{std::forward<args>(a)...});
} }
#else
inline void
ircd::log::log::error(const char *const &fmt,
...)
{
// Required in gcc 6.3.0 20170519, template param packs are not DCE'ed
}
#endif
#if RB_LOG_LEVEL >= 0
template<class... args> template<class... args>
void void
ircd::log::log::critical(const char *const &fmt, ircd::log::log::critical(const char *const &fmt,
@ -399,6 +543,14 @@ ircd::log::log::critical(const char *const &fmt,
{ {
operator()(facility::CRITICAL, fmt, va_rtti{std::forward<args>(a)...}); operator()(facility::CRITICAL, fmt, va_rtti{std::forward<args>(a)...});
} }
#else
inline void
ircd::log::log::critical(const char *const &fmt,
...)
{
// Required in gcc 6.3.0 20170519, template param packs are not DCE'ed
}
#endif
template<class... args> template<class... args>
void void