Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Single header with source code file #455

Merged
merged 15 commits into from
Jan 11, 2017
Merged
16 changes: 12 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
</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.
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.89. 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 @@ -451,7 +459,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 @@ -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
7 changes: 5 additions & 2 deletions doc/RELEASE-NOTES-v9.90
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
Easylogging++ v9.90 RELEASE NOTES
---------------------------------

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

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

==========================
= FIXES =
==========================
Expand All @@ -15,10 +17,11 @@ Breaking Change: Yes
= NEW FEATURES =
==========================

- The FormatSpecifierValueResolver function passed to the CustomFormatSpecifier constructor
- 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.
- Seperated header and source file (`easylogging++.h` and `easylogging++.cc`) (issue #445)

==========================
= NOTES =
Expand Down
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
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"
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
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
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"
1 change: 1 addition & 0 deletions samples/STL/shared-static-libs/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
lib/libmyLib.so
lib/easylogging++.o
lib/mylib.o
lib/myLib.a
myLib.a
Expand Down
9 changes: 5 additions & 4 deletions samples/STL/shared-static-libs/compile_shared.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ rm -rf libmyLib.so lib/libmyLib.so lib/mylib.o lib/myLib.a myLib.a myapp logs ##

compiler=g++
standard=c++0x ## If this does not work try c++11 (depends on your compiler)
macros="-DELPP_THREAD_SAFE -DELPP_STACKTRACE_ON_CRASH" ## Macros for library
macros="-DELPP_THREAD_SAFE -DELPP_FEATURE_CRASH_LOG" ## Macros for library

cd lib/
$compiler --std=$standard -pipe -fPIC -g -O0 $macros -Iinclude -c -o mylib.o mylib.cpp
$compiler -fPIC -g -shared -o libmyLib.so mylib.o
$compiler mylib.cpp ../../../../src/easylogging++.cc --std=$standard -pipe -fPIC -g -O0 $macros -Iinclude -c
$compiler -fPIC -g -shared -o libmyLib.so mylib.o easylogging++.o

cp libmyLib.so ..
cd ..
$compiler -g -std=$standard -fPIC -pipe -L lib myapp.cpp -Ilib/include -lmyLib -o myapp
$compiler -g -std=$standard -fPIC -pipe -L lib myapp.cpp ../../../src/easylogging++.cc -Ilib/include -lmyLib -o myapp
8 changes: 4 additions & 4 deletions samples/STL/shared-static-libs/compile_static.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ rm -rf libmyLib.so lib/libmyLib.so lib/mylib.o lib/myLib.a myLib.a myapp logs ##

compiler=g++
standard=c++0x ## If this does not work try c++11 (depends on your compiler)
macros="-DELPP_THREAD_SAFE -DELPP_STACKTRACE_ON_CRASH" ## Macros for library
macros="-DELPP_THREAD_SAFE -DELPP_FEATURE_CRASH_LOG" ## Macros for library

cd lib/
$compiler --std=$standard -pipe -fPIC -g -O0 $macros -Iinclude -c -o mylib.o mylib.cpp
ar rvs myLib.a mylib.o
$compiler --std=$standard -pipe -fPIC -g -O0 $macros -Iinclude -c mylib.cpp ../../../../src/easylogging++.cc
ar rvs myLib.a mylib.o easylogging++.o
cp myLib.a ..
cd ..
$compiler -g -std=$standard -o myapp myapp.cpp -Ilib/include myLib.a
$compiler -g -std=$standard -o myapp myapp.cpp ../../../src/easylogging++.cc -Ilib/include myLib.a
6 changes: 6 additions & 0 deletions samples/STL/shared-static-libs/easylogging++.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Header for sample that sub-includes original header from src/ folder
#ifndef EASYLOGGING_FOR_SAMPLES_H
#define EASYLOGGING_FOR_SAMPLES_H
# include "../../../src/easylogging++.h"
#endif // EASYLOGGING_FOR_SAMPLES_H

4 changes: 3 additions & 1 deletion samples/STL/shared-static-libs/myapp.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#include <mylib.hpp>

#include "easylogging++.h"
INITIALIZE_EASYLOGGINGPP
int main(int argc, char** argv) {
int result = 0;
LOG(INFO) << "Log from app";
//
// You can choose MyLib() constructor
// but be aware this will cause vlog to not work because Easylogging++
Expand Down
4 changes: 2 additions & 2 deletions samples/STL/shared-storage/compile_shared.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ rm -rf libmyLib.so lib/libmyLib.so lib/mylib.o lib/myLib.a myLib.a myapp logs ##

compiler=icpc
standard=c++0x ## If this does not work try c++11 (depends on your compiler)
macros="-DELPP_THREAD_SAFE -DELPP_STACKTRACE_ON_CRASH" ## Macros for library
macros="-DELPP_THREAD_SAFE -DELPP_FEATURE_CRASH_LOG" ## Macros for library

cd lib/
echo "$compiler --std=$standard -pipe -fPIC -g -O0 $macros -Iinclude -c mylib.cpp -o mylib.o"
$compiler --std=$standard -pipe -fPIC -g -O0 $macros -Iinclude -c mylib.cpp -o mylib.o
$compiler --std=$standard -pipe -fPIC -g -O0 $macros -Iinclude -c mylib.cpp -o mylib.o
echo "$compiler -fPIC -g -shared -o libmyLib.so mylib.o"
$compiler -fPIC -g -shared -o libmyLib.so mylib.o
cp libmyLib.so ..
Expand Down
4 changes: 2 additions & 2 deletions samples/async/build.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
compiler=$1
macros=""
macro="$macro -DELPP_FEATURE_ALL"
macros="$macros -DELPP_FEATURE_ALL"
if [ "$compiler" = "icpc" ];then
macros="$macros -DELPP_NO_SLEEP_FOR"
fi
echo "$compiler prog.cpp -DELPP_EXPERIMENTAL_ASYNC $macros -std=c++11 -lpthread -o prog"
echo "$compiler prog.cpp easylogging++.cc -DELPP_EXPERIMENTAL_ASYNC $macros -std=c++11 -lpthread -o prog"
$compiler prog.cpp -DELPP_EXPERIMENTAL_ASYNC $macros -std=c++11 -lpthread -o prog
1 change: 1 addition & 0 deletions samples/async/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/boost/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/boost/compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ FILE=$1
macro="$macro -DELPP_THREAD_SAFE"
macro="$macro -DELPP_STL_LOGGING"
macro="$macro -DELPP_BOOST_LOGGING"
macro="$macro -DELPP_STACKTRACE_ON_CRASH"
macro="$macro -DELPP_FEATURE_CRASH_LOG"
macro="$macro -DELPP_FEATURE_ALL"

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

echo "Compiling... [$FILE]"

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

echo " $COMPILE_LINE"

Expand Down
1 change: 1 addition & 0 deletions samples/boost/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/gtkmm/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/gtkmm/compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ FILE=$1

macro="$macro -DELPP_THREAD_SAFE"
macro="$macro -DELPP_STL_LOGGING"
macro="$macro -DELPP_STACKTRACE_ON_CRASH"
macro="$macro -DELPP_FEATURE_CRASH_LOG"
macro="$macro -DELPP_FEATURE_ALL"

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

echo "Compiling... [$FILE]"

COMPILE_LINE="$COMPILER $FILE `pkg-config --libs --cflags gtkmm-2.4 sigc++-2.0` -o bin/$FILE.bin $macro $CXX_STD -Wall -Wextra -Wundef"
COMPILE_LINE="$COMPILER $FILE easylogging++.cc `pkg-config --libs --cflags gtkmm-2.4 sigc++-2.0` -o bin/$FILE.bin $macro $CXX_STD -Wall -Wextra -Wundef"
echo " $COMPILE_LINE"

$($COMPILE_LINE)
Expand Down
1 change: 1 addition & 0 deletions samples/gtkmm/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/gtkmm/hello_gtkmm/compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

macro="$macro -DELPP_THREAD_SAFE"
macro="$macro -DELPP_STL_LOGGING"
macro="$macro -DELPP_STACKTRACE_ON_CRASH"
macro="$macro -DELPP_FEATURE_CRASH_LOG"

if [ "$1" = "" ];then
COMPILER=g++
Expand Down
2 changes: 1 addition & 1 deletion samples/wxWidgets/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/wxWidgets/compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ FILE=$1
macro="$macro -DELPP_THREAD_SAFE"
macro="$macro -DELPP_STL_LOGGING"
macro="$macro -DELPP_WXWIDGETS_LOGGING"
macro="$macro -DELPP_STACKTRACE_ON_CRASH"
macro="$macro -DELPP_FEATURE_CRASH_LOG"
macro="$macro -DELPP_FEATURE_ALL"

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

echo "Compiling... [$FILE]"

COMPILE_LINE="$COMPILER $FILE -o bin/$FILE.bin $macro $CXX_STD -Wall -Wextra `wx-config --cppflags` `wx-config --libs`"
COMPILE_LINE="$COMPILER $FILE easylogging++.cc -o bin/$FILE.bin $macro $CXX_STD -Wall -Wextra `wx-config --cppflags` `wx-config --libs`"

echo " $COMPILE_LINE"

Expand Down
1 change: 1 addition & 0 deletions samples/wxWidgets/easylogging++.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "../../src/easylogging++.cc"
Loading