Skip to content

Commit

Permalink
Merge pull request #461 from easylogging/develop
Browse files Browse the repository at this point in the history
v9.90 release
  • Loading branch information
abumq authored Jan 15, 2017
2 parents f950313 + 6871cad commit 84b702e
Show file tree
Hide file tree
Showing 164 changed files with 3,455 additions and 2,907 deletions.
8 changes: 5 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
cmake_minimum_required(VERSION 3.1)
cmake_minimum_required(VERSION 2.8)

project(Easyloggingpp CXX)

set(ELPP_MAJOR_VERSION "9")
set(ELPP_MINOR_VERSION "89")
set(ELPP_MINOR_VERSION "90")
set(ELPP_VERSION_STRING "${ELPP_MAJOR_VERSION}.${ELPP_MINOR_VERSION}")

set(ELPP_INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/include" CACHE PATH "The directory the headers are installed in")

include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)

install(FILES src/easylogging++.h
install(FILES
src/easylogging++.h
src/easylogging++.cc
DESTINATION "${ELPP_INCLUDE_INSTALL_DIR}"
COMPONENT dev)

Expand Down
34 changes: 21 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
‫بسم الله الرَّحْمَنِ الرَّحِيمِ


> **Manual For v9.89**
> **Manual For v9.90**
>
> [![Build Status](https://travis-ci.org/easylogging/easyloggingpp.png?branch=develop)](https://travis-ci.org/easylogging/easyloggingpp)
### Quick Links

[![download] Latest Release](https://github.com/easylogging/easyloggingpp/releases/latest)

[![notes] Release Notes](https://github.com/easylogging/easyloggingpp/tree/master/doc/RELEASE-NOTES-v9.89)
[![notes] Release Notes](https://github.com/easylogging/easyloggingpp/tree/master/doc/RELEASE-NOTES-v9.90)

[![samples] Samples](https://github.com/easylogging/easyloggingpp/tree/v9.89/samples)
[![samples] Samples](https://github.com/easylogging/easyloggingpp/tree/v9.90/samples)

[![paypal]](http://muflihun.com/support/)

Expand Down Expand Up @@ -93,8 +93,8 @@
</pre>

# Introduction
Easylogging++ is single header only, feature-rich, efficient logging library for C++ applications. It has been written keeping three things in mind; performance, management (setup, configure, logging, simplicity) and portability. Its highly configurable and extremely useful for small to large sized projects.
This manual is for Easylogging++ v9.89. For other versions please refer to corresponding [release](https://github.com/easylogging/easyloggingpp/releases) on github.
Easylogging++ is single header, feature-rich, efficient logging library for C++ applications. It has been written keeping three things in mind; performance, management (setup, configure, logging, simplicity) and portability. Its highly configurable and extremely useful for small to large sized projects.
This manual is for Easylogging++ v9.90. For other versions please refer to corresponding [release](https://github.com/easylogging/easyloggingpp/releases) on github.

[![top] Goto Top](#table-of-contents)

Expand Down Expand Up @@ -135,7 +135,7 @@ For other releases, please visit [releases page](https://github.com/easylogging/
### Quick Start
In order to get started with Easylogging++, you can follow three easy steps:
* Download latest version
* Include into your project
* Include into your project (`easylogging++.h` and `easylogging++.cc`)
* Initialize using single macro... and off you go!

```c++
Expand All @@ -149,6 +149,12 @@ int main(int argc, char* argv[]) {
}
```
Now compile using
```
g++ main.cc easylogging++.cc -o prog -std=c++11
```
That simple! Please note that `INITIALIZE_EASYLOGGINGPP` should be used once and once-only otherwise you will end up getting compilation errors. This is definiting several `extern` variables. This means it can be defined only once per application. Best place to put this initialization statement is in file where `int main(int, char**)` function is defined, right after last include statement.
### Install (Optional)
Expand All @@ -161,6 +167,8 @@ make
make install
```
With that said, you will still need `easylogging++.cc` file in order to compile. For header only, please check [v9.89](https://github.com/easylogging/easyloggingpp/releases/tag/9.89) and lower.
[![top] Goto Top](#table-of-contents)
### Setting Application Arguments
Expand Down Expand Up @@ -216,7 +224,7 @@ Following table contains configurations supported by configuration file.
| `To_Standard_Output` | bool | Whether or not to write logs to standard output e.g, terminal or command prompt |
| `Format` | char* | Determines format/pattern of logging for corresponding level and logger. |
| `Filename` | char* | Determines log file (full path) to write logs to for corresponding level and logger |
| `Milliseconds_Width` | uint | Specifies milliseconds width. Width can be within range (1-6) |
| `Subsecond_Precision` | uint | Specifies subsecond precision (previously called 'milliseconds width'). Width can be within range (1-6) |
| `Performance_Tracking` | bool | Determines whether or not performance tracking is enabled. This does not depend on logger or level. Performance tracking always uses 'performance' logger unless specified|
| `Max_Log_File_Size` | size_t | If log file size of corresponding level is >= specified size, log file will be truncated. |
| `Log_Flush_Threshold` | size_t | Specifies number of log entries to hold until we flush pending log data |
Expand All @@ -232,7 +240,7 @@ Sample Configuration File
ENABLED = true
TO_FILE = true
TO_STANDARD_OUTPUT = true
MILLISECONDS_WIDTH = 6
SUBSECOND_PRECISION = 6
PERFORMANCE_TRACKING = true
MAX_LOG_FILE_SIZE = 2097152 ## 2MB - Comment starts with two hashes (##)
LOG_FLUSH_THRESHOLD = 100 ## Flush after every 100 logs
Expand Down Expand Up @@ -391,7 +399,7 @@ You can customize date/time format using following specifiers
| `%H` | Hour (24-hour format) |
| `%m` | Minute (zero-padded) |
| `%s` | Second (zero-padded) |
| `%g` | Milliseconds (width is configured by ConfigurationType::MillisecondsWidth) |
| `%g` | Subsecond part (precision is configured by ConfigurationType::MillisecondsWidth) |
| `%F` | AM/PM designation |
| `%` | Escape character |

Expand Down Expand Up @@ -424,6 +432,8 @@ You can set/unset these flags by using static `el::Loggers::addFlag` and `el::Lo

> You can set these flags by using `--logging-flags` command line arg. You need to enable this functionality by defining macro `ELPP_LOGGING_FLAGS_FROM_ARG` (You will need to make sure to use `START_EASYLOGGINGPP(argc, argv)` to configure arguments).
> You can also set default (initial) flags using `ELPP_DEFAULT_LOGGING_FLAGS` and set numerical value for initial flags
[![top] Goto Top](#table-of-contents)

### Application Arguments
Expand Down Expand Up @@ -451,7 +461,7 @@ NOTE: All the macros either need to be defined before `#include "easylogging++"`
| `ELPP_UNICODE` | Enables Unicode support when logging. Requires `START_EASYLOGGINGPP` |
| `ELPP_THREAD_SAFE` | Enables thread-safety - make sure -lpthread linking for linux. |
| `ELPP_FORCE_USE_STD_THREAD` | Forces to use C++ standard library for threading (Only useful when using `ELPP_THREAD_SAFE` |
| `ELPP_STACKTRACE_ON_CRASH` | Applicable to GCC only. Enables stacktrace on application crash |
| `ELPP_FEATURE_CRASH_LOG` | Applicable to GCC only. Enables stacktrace on application crash |
| `ELPP_DISABLE_DEFAULT_CRASH_HANDLING` | Disables default crash handling. You can use el::Helpers::setCrashHandler to use your own handler. |
| `ELPP_DISABLE_LOGS` | Disables all logs - (preprocessing) |
| `ELPP_DISABLE_DEBUG_LOGS` | Disables debug logs - (preprocessing) |
Expand Down Expand Up @@ -719,8 +729,6 @@ Let's say we have an application that uses easylogging++ and has it's own config
* Instead of using `INITIALIZE_EASYLOGGINGPP` you use `SHARE_EASYLOGGINGPP(access-function-to-repository)`
* Instead of using `INITIALIZE_EASYLOGGINGPP` you use `INITIALIZE_NULL_EASYLOGGINGPP` and then `el::Helpers::setStorage(el::base::type::StoragePointer)`

Refer [this](https://github.com/easylogging/easyloggingpp/blob/master/samples/STL/shared-storage) for details

After you share repository, you can reconfigure the only repository (i.e, the one that is used by application and library both), and use both to write logs. A very good example is in `samples/VC++/DLLSample`

[![top] Goto Top](#table-of-contents)
Expand Down Expand Up @@ -898,7 +906,7 @@ Following signals are handled;
* SIGSEGV
* SIGINT
Stacktraces are not printed by default, in order to do so define macro `ELPP_STACKTRACE_ON_CRASH`. Remember, stack trace is only available for GCC compiler.
Stacktraces are not printed by default, in order to do so define macro `ELPP_FEATURE_CRASH_LOG`. Remember, stack trace is only available for GCC compiler.
> Default handler and stack trace uses `default` logger.
Expand Down
5 changes: 4 additions & 1 deletion cmake/FindEasyloggingpp.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
# $EASYLOGGINGPP_ROOT is an environment variable that
# would correspond to the installation path.
#
# http://easylogging.muflihun.com
# http://muflihun.com
#

set(EASYLOGGINGPP_PATHS ${EASYLOGGINGPP_ROOT} $ENV{EASYLOGGINGPP_ROOT})

Expand All @@ -20,4 +23,4 @@ find_path(EASYLOGGINGPP_INCLUDE_DIR

include(FindPackageHandleStandardArgs)

find_package_handle_standard_args(EASYLOGGINGPP REQUIRED_VARS EASYLOGGINGPP_INCLUDE_DIR)
find_package_handle_standard_args(EASYLOGGINGPP REQUIRED_VARS EASYLOGGINGPP_INCLUDE_DIR)
Empty file modified doc/RELEASE-NOTES-v9.00
100755 → 100644
Empty file.
Empty file modified doc/RELEASE-NOTES-v9.01
100755 → 100644
Empty file.
Empty file modified doc/RELEASE-NOTES-v9.02
100755 → 100644
Empty file.
Empty file modified doc/RELEASE-NOTES-v9.03
100755 → 100644
Empty file.
Empty file modified doc/RELEASE-NOTES-v9.04
100755 → 100644
Empty file.
Empty file modified doc/RELEASE-NOTES-v9.05
100755 → 100644
Empty file.
Empty file modified doc/RELEASE-NOTES-v9.06
100755 → 100644
Empty file.
Empty file modified doc/RELEASE-NOTES-v9.07
100755 → 100644
Empty file.
Empty file modified doc/RELEASE-NOTES-v9.08
100755 → 100644
Empty file.
Empty file modified doc/RELEASE-NOTES-v9.09
100755 → 100644
Empty file.
Empty file modified doc/RELEASE-NOTES-v9.10
100755 → 100644
Empty file.
Empty file modified doc/RELEASE-NOTES-v9.11
100755 → 100644
Empty file.
Empty file modified doc/RELEASE-NOTES-v9.12
100755 → 100644
Empty file.
Empty file modified doc/RELEASE-NOTES-v9.13
100755 → 100644
Empty file.
Empty file modified doc/RELEASE-NOTES-v9.14
100755 → 100644
Empty file.
Empty file modified doc/RELEASE-NOTES-v9.15
100755 → 100644
Empty file.
Empty file modified doc/RELEASE-NOTES-v9.16
100755 → 100644
Empty file.
Empty file modified doc/RELEASE-NOTES-v9.17
100755 → 100644
Empty file.
Empty file modified doc/RELEASE-NOTES-v9.18
100755 → 100644
Empty file.
Empty file modified doc/RELEASE-NOTES-v9.19
100755 → 100644
Empty file.
Empty file modified doc/RELEASE-NOTES-v9.20
100755 → 100644
Empty file.
Empty file modified doc/RELEASE-NOTES-v9.21
100755 → 100644
Empty file.
Empty file modified doc/RELEASE-NOTES-v9.22
100755 → 100644
Empty file.
Empty file modified doc/RELEASE-NOTES-v9.23
100755 → 100644
Empty file.
Empty file modified doc/RELEASE-NOTES-v9.24
100755 → 100644
Empty file.
Empty file modified doc/RELEASE-NOTES-v9.25
100755 → 100644
Empty file.
Empty file modified doc/RELEASE-NOTES-v9.26
100755 → 100644
Empty file.
Empty file modified doc/RELEASE-NOTES-v9.27
100755 → 100644
Empty file.
Empty file modified doc/RELEASE-NOTES-v9.28
100755 → 100644
Empty file.
Empty file modified doc/RELEASE-NOTES-v9.29
100755 → 100644
Empty file.
Empty file modified doc/RELEASE-NOTES-v9.30
100755 → 100644
Empty file.
Empty file modified doc/RELEASE-NOTES-v9.31
100755 → 100644
Empty file.
Empty file modified doc/RELEASE-NOTES-v9.32
100755 → 100644
Empty file.
Empty file modified doc/RELEASE-NOTES-v9.33
100755 → 100644
Empty file.
Empty file modified doc/RELEASE-NOTES-v9.34
100755 → 100644
Empty file.
Empty file modified doc/RELEASE-NOTES-v9.35
100755 → 100644
Empty file.
Empty file modified doc/RELEASE-NOTES-v9.36
100755 → 100644
Empty file.
Empty file modified doc/RELEASE-NOTES-v9.37
100755 → 100644
Empty file.
Empty file modified doc/RELEASE-NOTES-v9.38
100755 → 100644
Empty file.
Empty file modified doc/RELEASE-NOTES-v9.39
100755 → 100644
Empty file.
Empty file modified doc/RELEASE-NOTES-v9.40
100755 → 100644
Empty file.
Empty file modified doc/RELEASE-NOTES-v9.41
100755 → 100644
Empty file.
Empty file modified doc/RELEASE-NOTES-v9.42
100755 → 100644
Empty file.
Empty file modified doc/RELEASE-NOTES-v9.43
100755 → 100644
Empty file.
Empty file modified doc/RELEASE-NOTES-v9.44
100755 → 100644
Empty file.
Empty file modified doc/RELEASE-NOTES-v9.45
100755 → 100644
Empty file.
Empty file modified doc/RELEASE-NOTES-v9.46
100755 → 100644
Empty file.
Empty file modified doc/RELEASE-NOTES-v9.47
100755 → 100644
Empty file.
Empty file modified doc/RELEASE-NOTES-v9.48
100755 → 100644
Empty file.
Empty file modified doc/RELEASE-NOTES-v9.49
100755 → 100644
Empty file.
Empty file modified doc/RELEASE-NOTES-v9.50
100755 → 100644
Empty file.
Empty file modified doc/RELEASE-NOTES-v9.51
100755 → 100644
Empty file.
Empty file modified doc/RELEASE-NOTES-v9.52
100755 → 100644
Empty file.
Empty file modified doc/RELEASE-NOTES-v9.53
100755 → 100644
Empty file.
Empty file modified doc/RELEASE-NOTES-v9.54
100755 → 100644
Empty file.
Empty file modified doc/RELEASE-NOTES-v9.55
100755 → 100644
Empty file.
Empty file modified doc/RELEASE-NOTES-v9.56
100755 → 100644
Empty file.
Empty file modified doc/RELEASE-NOTES-v9.57
100755 → 100644
Empty file.
Empty file modified doc/RELEASE-NOTES-v9.58
100755 → 100644
Empty file.
Empty file modified doc/RELEASE-NOTES-v9.59
100755 → 100644
Empty file.
Empty file modified doc/RELEASE-NOTES-v9.60
100755 → 100644
Empty file.
Empty file modified doc/RELEASE-NOTES-v9.61
100755 → 100644
Empty file.
Empty file modified doc/RELEASE-NOTES-v9.62
100755 → 100644
Empty file.
Empty file modified doc/RELEASE-NOTES-v9.63
100755 → 100644
Empty file.
Empty file modified doc/RELEASE-NOTES-v9.64
100755 → 100644
Empty file.
Empty file modified doc/RELEASE-NOTES-v9.65
100755 → 100644
Empty file.
Empty file modified doc/RELEASE-NOTES-v9.66
100755 → 100644
Empty file.
Empty file modified doc/RELEASE-NOTES-v9.67
100755 → 100644
Empty file.
Empty file modified doc/RELEASE-NOTES-v9.68
100755 → 100644
Empty file.
Empty file modified doc/RELEASE-NOTES-v9.69
100755 → 100644
Empty file.
Empty file modified doc/RELEASE-NOTES-v9.70
100755 → 100644
Empty file.
Empty file modified doc/RELEASE-NOTES-v9.71
100755 → 100644
Empty file.
Empty file modified doc/RELEASE-NOTES-v9.72
100755 → 100644
Empty file.
Empty file modified doc/RELEASE-NOTES-v9.73
100755 → 100644
Empty file.
Empty file modified doc/RELEASE-NOTES-v9.74
100755 → 100644
Empty file.
Empty file modified doc/RELEASE-NOTES-v9.75
100755 → 100644
Empty file.
Empty file modified doc/RELEASE-NOTES-v9.76
100755 → 100644
Empty file.
Empty file modified doc/RELEASE-NOTES-v9.77
100755 → 100644
Empty file.
Empty file modified doc/RELEASE-NOTES-v9.78
100755 → 100644
Empty file.
Empty file modified doc/RELEASE-NOTES-v9.79
100755 → 100644
Empty file.
Empty file modified doc/RELEASE-NOTES-v9.80
100755 → 100644
Empty file.
Empty file modified doc/RELEASE-NOTES-v9.81
100755 → 100644
Empty file.
Empty file modified doc/RELEASE-NOTES-v9.82
100755 → 100644
Empty file.
Empty file modified doc/RELEASE-NOTES-v9.83
100755 → 100644
Empty file.
Empty file modified doc/RELEASE-NOTES-v9.84
100755 → 100644
Empty file.
Empty file modified doc/RELEASE-NOTES-v9.85
100755 → 100644
Empty file.
Empty file modified doc/RELEASE-NOTES-v9.86
100755 → 100644
Empty file.
Empty file modified doc/RELEASE-NOTES-v9.87
100755 → 100644
Empty file.
Empty file modified doc/RELEASE-NOTES-v9.88
100755 → 100644
Empty file.
Empty file modified doc/RELEASE-NOTES-v9.89
100755 → 100644
Empty file.
34 changes: 34 additions & 0 deletions doc/RELEASE-NOTES-v9.90
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
Easylogging++ v9.90 RELEASE NOTES
---------------------------------

Release type: Major
API changes: Yes
Breaking Change: Yes

This is a major release. We have separated header file in to `easylogging++.h` and `easylogging++.cc`. Source file (`easylogging++.cc`) encompass source to speed up compile time. Thanks to @aparajita.

==========================
= FIXES =
==========================

- Fix to custom datetime format in Unicode mode

==========================
= NEW FEATURES =
==========================

- The `FormatSpecifierValueResolver` function passed to the `CustomFormatSpecifier` constructor
now receives `const LogMessage&` as an argument. This allows you to access message-specific context
(such as the verbose level) within your custom formatting function. For an example, see
samples/STL/custom-format-spec.cpp.
- Separated header and source file (`easylogging++.h` and `easylogging++.cc`) (issue #445)
- New `ELPP_DEFAULT_LOGGING_FLAGS` macro for setting initial logging flags
- C++11 detection is improved, and Clang uses `std::thread` by default if it is available

==========================
= NOTES =
==========================

- See https://github.com/easylogging/easyloggingpp/blob/v9.90/README.md for manual for this release
- See https://github.com/easylogging/easyloggingpp/tree/master/doc for other release notes
- Closed issues: https://github.com/easylogging/easyloggingpp/issues?page=1&state=closed
2 changes: 1 addition & 1 deletion samples/API/build_all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[ -d "bin" ] || mkdir "bin"
rm -rf bin/*

find -maxdepth 1 -type f -name '*.cpp' -exec sh compile.sh {} $1 \;
find . -maxdepth 1 -type f -name '*.cpp' -exec sh compile.sh {} $1 \;
echo "Completed!"

files=$(ls -l bin/)
Expand Down
4 changes: 2 additions & 2 deletions samples/API/compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ macro="$macro -DELPP_THREAD_SAFE"
macro="$macro -DELPP_STL_LOGGING"
macro="$macro -DELPP_LOG_UNORDERED_SET"
macro="$macro -DELPP_LOG_UNORDERED_MAP"
macro="$macro -DELPP_STACKTRACE_ON_CRASH"
macro="$macro -DELPP_FEATURE_CRASH_LOG"
macro="$macro -DELPP_FEATURE_ALL"

if [ "$2" = "" ];then
Expand All @@ -24,7 +24,7 @@ fi

echo "Compiling... [$FILE]"

COMPILE_LINE="$COMPILER $FILE -o bin/$FILE.bin $macro $CXX_STD -Wall -Wextra -pedantic -pedantic-errors -Werror -Wfatal-errors"
COMPILE_LINE="$COMPILER $FILE easylogging++.cc -o bin/$FILE.bin $macro $CXX_STD -Wall -Wextra -pedantic -pedantic-errors -Werror -Wfatal-errors"

echo " $COMPILE_LINE"

Expand Down
1 change: 1 addition & 0 deletions samples/API/easylogging++.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "../../src/easylogging++.cc"
2 changes: 1 addition & 1 deletion samples/MinGW/prog.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#define ELPP_STL_LOGGING
// #define ELPP_STACKTRACE_ON_CRASH -- Stack trace not available for MinGW GCC
// #define ELPP_FEATURE_CRASH_LOG -- Stack trace not available for MinGW GCC
#define ELPP_PERFORMANCE_MICROSECONDS
#define ELPP_LOG_STD_ARRAY
#define ELPP_LOG_UNORDERED_MAP
Expand Down
Empty file modified samples/OpenGL/Cube/Makefile
100755 → 100644
Empty file.
Empty file modified samples/OpenGL/Cube/vtr.bmp
100755 → 100644
Empty file.
4 changes: 2 additions & 2 deletions samples/OpenGL/compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ macro="$macro -DELPP_STL_LOGGING"
macro="$macro -DELPP_LOG_STD_ARRAY"
macro="$macro -DELPP_LOG_UNORDERED_SET"
macro="$macro -DELPP_LOG_UNORDERED_MAP"
macro="$macro -DELPP_STACKTRACE_ON_CRASH"
macro="$macro -DELPP_FEATURE_CRASH_LOG"
macro="$macro -DELPP_FEATURE_ALL"

if [ "$2" = "" ];then
Expand All @@ -25,7 +25,7 @@ fi

echo "Compiling... [$FILE]"

COMPILE_LINE="$COMPILER $FILE -o bin/$FILE.bin $macro $CXX_STD -Wall -Wextra -lglut -lGLU -lGL -I/usr/include/x86_64-linux-gnu/c++/4.7/"
COMPILE_LINE="$COMPILER $FILE easylogging++.cc -o bin/$FILE.bin $macro $CXX_STD -Wall -Wextra -lglut -lGLU -lGL -I/usr/include/x86_64-linux-gnu/c++/4.7/"

echo " $COMPILE_LINE"

Expand Down
1 change: 1 addition & 0 deletions samples/OpenGL/easylogging++.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "../../src/easylogging++.cc"
2 changes: 1 addition & 1 deletion samples/Qt/basic/test_conf.conf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
ENABLED = true
TO_FILE = true
TO_STANDARD_OUTPUT = true
MILLISECONDS_WIDTH = 6
SUBSECOND_PRECISION = 6
PERFORMANCE_TRACKING = false
MAX_LOG_FILE_SIZE = 1024
* WARNING:
Expand Down
4 changes: 2 additions & 2 deletions samples/Qt/fast-dictionary/fast-dictionary.pro
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ QMAKE_CXX = $$COMPILER
QMAKE_LINK = $$COMPILER

QMAKE_CXXFLAGS += -std=c++0x
DEFINES += ELPP_STACKTRACE_ON_CRASH \
DEFINES += ELPP_FEATURE_CRASH_LOG \
ELPP_FEATURE_ALL \
ELPP_MULTI_LOGGER_SUPPORT

SOURCES += main.cc\
mainwindow.cc \
listwithsearch.cc
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ DEFINES += ELPP_QT_LOGGING \
ELPP_FEATURE_ALL \
ELPP_STL_LOGGING \
ELPP_STRICT_SIZE_CHECK \
ELPP_STACKTRACE_ON_CRASH \
ELPP_FEATURE_CRASH_LOG \
ELPP_THREAD_SAFE

COMPILER = g++
Expand Down
Empty file modified samples/Qt/shared-lib/myapp/easylogging++.h
100755 → 100644
Empty file.
Empty file modified samples/Qt/shared-lib/myapp/main.cc
100755 → 100644
Empty file.
Empty file modified samples/Qt/shared-lib/myapp/myapp.pro
100755 → 100644
Empty file.
4 changes: 2 additions & 2 deletions samples/STL/compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ macro="$macro -DELPP_THREAD_SAFE"
macro="$macro -DELPP_STL_LOGGING"
macro="$macro -DELPP_LOG_UNORDERED_SET"
macro="$macro -DELPP_LOG_UNORDERED_MAP"
macro="$macro -DELPP_STACKTRACE_ON_CRASH"
macro="$macro -DELPP_FEATURE_CRASH_LOG"
macro="$macro -DELPP_LOGGING_FLAGS_FROM_ARG"
macro="$macro -DELPP_FEATURE_ALL"
# macro="$macro -DELPP_DEFAULT_LOG_FILE=\"/a/path/that/does/not/exist/f.log\""
Expand All @@ -27,7 +27,7 @@ fi

echo "Compiling... [$FILE]"

COMPILE_LINE="$COMPILER $FILE -o bin/$FILE.bin $macro $CXX_STD -Wall -Wextra -pedantic -pedantic-errors -Werror -Wfatal-errors -Wundef -Wunused"
COMPILE_LINE="$COMPILER $FILE easylogging++.cc -o bin/$FILE.bin $macro $CXX_STD -Wall -Wextra -pedantic -pedantic-errors -Werror -Wfatal-errors -Wundef -Wunused"

echo " $COMPILE_LINE"

Expand Down
57 changes: 54 additions & 3 deletions samples/STL/custom-format-spec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,84 @@
//
// Custom format specifier to demonstrate usage of el::Helpers::installCustomFormatSpecifier
//
// Revision 1.1
// Revision 1.2
// @author mkhan3189
//

#include "easylogging++.h"

INITIALIZE_EASYLOGGINGPP

enum ELogLevel : el::base::type::VerboseLevel {
kLogLevel_Off = 0,
kLogLevel_Error,
kLogLevel_Warning,
kLogLevel_Info,
kLogLevel_Debug,
kLogLevel_Verbose
};

static std::map<ELogLevel, std::string> sSeverityMap {
{ kLogLevel_Error, "ouch!" },
{ kLogLevel_Warning, "oops" },
{ kLogLevel_Info, "hey" },
{ kLogLevel_Debug, "debugging" },
{ kLogLevel_Verbose, "loquacious" }
};

const char*
getSeverity(const el::LogMessage* message) {
return sSeverityMap[static_cast<ELogLevel>(message->verboseLevel())].c_str();
}

class HttpRequest {
public:
const char* getIp(void) {
const char* getIp(const el::LogMessage*) {
return "192.168.1.1";
}
};

int main(void) {
using namespace std::placeholders;

HttpRequest request;

// Install format specifier
el::Helpers::installCustomFormatSpecifier(el::CustomFormatSpecifier("%ip_addr", std::bind(&HttpRequest::getIp, request)));
el::Helpers::installCustomFormatSpecifier(el::CustomFormatSpecifier("%ip_addr", std::bind(&HttpRequest::getIp, request, _1)));
// Either you can do what's done above (for member function) or if you have static function you can simply say
// el::CustomFormatSpecifier("%ip_addr", getIp)

// Configure loggers
el::Loggers::reconfigureAllLoggers(el::ConfigurationType::Format, "%datetime %level %ip_addr : %msg");
LOG(INFO) << "This is after installed 'ip_addr' spec";

// Uninstall custom format specifier
el::Helpers::uninstallCustomFormatSpecifier("%ip_addr");
LOG(INFO) << "This is after uninstalled";

// Install format specifier
el::Helpers::installCustomFormatSpecifier(el::CustomFormatSpecifier("%severity", getSeverity));

// Configure loggers
el::Loggers::reconfigureAllLoggers(el::ConfigurationType::Format, "%datetime{%b %d %H:%m:%s}: [%severity] %msg");
el::Loggers::setVerboseLevel(kLogLevel_Verbose);

VLOG(kLogLevel_Info) << "Installed 'severity' custom formatter";
VLOG(kLogLevel_Error) << "This is an error";
VLOG(kLogLevel_Warning) << "This is a warning";
VLOG(kLogLevel_Info) << "This is info";
VLOG(kLogLevel_Debug) << "This is debug";
VLOG(kLogLevel_Verbose) << "This is verbose";

// Uninstall custom format specifier
el::Helpers::uninstallCustomFormatSpecifier("%severity");

VLOG(kLogLevel_Info) << "Uninstalled 'severity' custom formatter";
VLOG(kLogLevel_Error) << "This is an error";
VLOG(kLogLevel_Warning) << "This is a warning";
VLOG(kLogLevel_Info) << "This is info";
VLOG(kLogLevel_Debug) << "This is debug";
VLOG(kLogLevel_Verbose) << "This is verbose";

return 0;
}
1 change: 1 addition & 0 deletions samples/STL/easylogging++.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "../../src/easylogging++.cc"
Loading

0 comments on commit 84b702e

Please sign in to comment.