Skip to content

Commit

Permalink
Add LOGURU_RTTI and LOGURU_STACKTRACES settings
Browse files Browse the repository at this point in the history
  • Loading branch information
emilk committed Jan 3, 2018
1 parent c482a85 commit 08baf62
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 14 deletions.
40 changes: 26 additions & 14 deletions loguru.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ Website: www.ilikebigbits.com
* Version 1.4.1 - 2016-09-29 - Customize formating with LOGURU_FILENAME_WIDTH
* Version 1.5.0 - 2016-12-22 - LOGURU_USE_FMTLIB by kolis and LOGURU_WITH_FILEABS by scinart
* Version 1.5.1 - 2017-08-08 - Terminal colors on Windows 10 thanks to looki
* Version 1.6.0 - 2018-01-03 - Add LOGURU_RTTI and LOGURU_STACKTRACES settings
# Compiling
Just include <loguru.hpp> where you want to use Loguru.
Expand Down Expand Up @@ -149,6 +150,12 @@ Website: www.ilikebigbits.com
Such a scheme is useful if you have a daemon program that moves the log file every 24 hours and expects new file to be created.
Feature by scinart (https://github.com/emilk/loguru/pull/23).
LOGURU_STACKTRACES (default 1 on supported platforms):
Print stack traces on abort.
LOGURU_RTTI (default 1):
Set to 0 if your platform does not support runtime type information (-fno-rtti).
You can also configure:
loguru::g_flush_interval_ms:
If set to zero Loguru will flush on every line (unbuffered mode).
Expand Down Expand Up @@ -232,6 +239,10 @@ Website: www.ilikebigbits.com
#define LOGURU_WITH_FILEABS 0
#endif

#ifndef LOGURU_RTTI
#define LOGURU_RTTI 1
#endif

// --------------------------------------------------------------------
// Utility macros

Expand Down Expand Up @@ -2156,17 +2167,22 @@ namespace loguru
return result;
}

template <class T>
std::string type_name() {
auto demangled = demangle(typeid(T).name());
return demangled.c_str();
}
#if LOGURU_RTTI
template <class T>
std::string type_name()
{
auto demangled = demangle(typeid(T).name());
return demangled.c_str();
}
#endif // LOGURU_RTTI

static const StringPairList REPLACE_LIST = {
{ type_name<std::string>(), "std::string" },
{ type_name<std::wstring>(), "std::wstring" },
{ type_name<std::u16string>(), "std::u16string" },
{ type_name<std::u32string>(), "std::u32string" },
#if LOGURU_RTTI
{ type_name<std::string>(), "std::string" },
{ type_name<std::wstring>(), "std::wstring" },
{ type_name<std::u16string>(), "std::u16string" },
{ type_name<std::u32string>(), "std::u32string" },
#endif // LOGURU_RTTI
{ "std::__1::", "std::" },
{ "__thiscall ", "" },
{ "__cdecl ", "" },
Expand Down Expand Up @@ -2260,11 +2276,7 @@ namespace loguru

std::string stacktrace_as_stdstring(int)
{
#if defined(_MSC_VER)
#pragma message ( "Loguru: No stacktraces available on this platform" )
#else
#warning "Loguru: No stacktraces available on this platform"
#endif
// No stacktraces available on this platform"
return "";
}

Expand Down
2 changes: 2 additions & 0 deletions test/loguru_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#define LOGURU_USE_FMTLIB 0
#define LOGURU_WITH_FILEABS 0
#define LOGURU_IMPLEMENTATION 1
// #define LOGURU_STACKTRACES 1
// #define LOGURU_RTTI 1
#include "../loguru.hpp"

#include <chrono>
Expand Down

0 comments on commit 08baf62

Please sign in to comment.