mirror of
https://github.com/vgough/encfs.git
synced 2025-02-21 12:11:12 +01:00
Squashed 'vendor/github.com/muflihun/easyloggingpp/' changes from 468597048..49da71da8
49da71da8 Merge pull request #775 from amrayn/develop fa10a7974 Merge branch 'master' into develop 24b0de3d6 Merge pull request #702 from moneromooo-monero/dateIndex 5b55576b7 Merge pull request #647 from agilmor/readme_minor_fix 149000493 Merge pull request #714 from adah1972/typo-change 6cb5e4e52 Merge branch 'master' into typo-change a41864de6 Merge pull request #725 from divinity76/patch-1 a2d78625c Merge pull request #705 from markus-k/qnx-support cc35e9627 Merge pull request #739 from adam1985d/master 75d181c5c Merge pull request #774 from amrayn/develop d3e56c04f Merge pull request #712 from KrusnikViers/remove-unused-variable 83f7b0c03 Merge pull request #735 from ndowens/master 9d35a7e15 Merge pull request #726 from recipe/patch-1 0df4c5ad8 Merge pull request #737 from PhoebeHui/dev/Phoebe/vcpkg_instructions 7f8761b48 Merge pull request #741 from DominionSoftware/add_try_catch e5b4e2d80 Merge pull request #746 from soyoo/patch-1 e6594d8ef Merge pull request #773 from amrayn/develop f68abe86a Merge pull request #757 from jsoref/spelling 769b39d8e Merge pull request #748 from soyoo/patch-2 796565c05 spelling: unknown 84719eef7 spelling: specified 23ff0cbff spelling: situations ee76a6a32 spelling: separator a4d0753f4 spelling: separate 5b522401a spelling: sensitive bea320906 spelling: registries 01a7be37d spelling: program 64856cfd6 spelling: performance 11233adaf spelling: overridden e6f376e10 spelling: original a78650209 spelling: occurred f5bc5df27 spelling: occasional ... ecb10dc07 spelling: javascript fa5148d85 spelling: insensitive 336f3e5e4 spelling: instance e88a535cd spelling: improvement 68bfc9d45 spelling: features 0134dfdf3 spelling: experimental 6df775fbe spelling: ditched 267d90dbc spelling: disabled 66cc3067d spelling: defining 872c0777b spelling: corruption 20a8c30b1 spelling: corresponding f59a4b7f7 spelling: converts 357e5d8dd spelling: configuration 794dd51ef spelling: compliant 66e452eb5 spelling: attempted f316282c0 spelling: assuming 05d596f8e spelling: arithmetic 41b5d377a spelling: april 7bc7d6dea spelling: alpha 210ea0213 Update easylogging++.cc bb0f45c83 Update easyloggingpp.pri 03694bdce Create easyloggingpp.pri 95324817b Merge pull request #743 from benrubson/warn fcf9c6cf2 kSysLogLoggerId defined but not used f18f75cf7 add try catch to handle extremely low memory condition 733d9e749 Merge pull request #1 from amrayn/master 163a8e538 Update README.md 32415d9b3 bug - access attempt to released memory 15e2018ec Add vcpkg installation instructions 60d92a867 Add if defined HAVE_EXECINFO 2a171bc91 Merge pull request #728 from amrayn/develop b7e58d940 Merge branch 'master' into develop 3ec5bb3ae update e00090395 Create FUNDING.yml 2521c4875 typo 8e334dfd5 disable ELPP_STACKTRACE for cygwin a5070d23d Fix two typos that could affect understanding. 438c34cc6 Comment unused variable f5f213459 Disable stacktrace feature on QNX 573a51be4 Add support for QNX a441d4464 Fix using invalid dateIndex (std::string::npos) 20fdea6e1 Merge pull request #689 from zuhd-org/develop ca4f51f39 updated build matrix links bd593b386 Merge pull request #685 from zuhd-org/develop d97dbef47 Update README.md 5181b4039 Merge pull request #684 from muflihun/develop 25ebd5adf Update README.md f3986aaeb Merge pull request #683 from muflihun/develop e4659e547 9.96.7 release ea8e806b9 Merge pull request #642 from SgtCoDFish/develop fd2dda331 Merge branch 'develop' into develop dafba610c Merge pull request #682 from muflihun/develop bbdb96c39 updated release babf11834 updated license ebc066f71 Merge pull request #645 from slaperche-scality/support_pic_code cda4f5346 generate PIC code for the library 72436e541 Fixed unused variable warning while build without performance logging feature 3a832d738 Fix #660 (accessing ELPP before it's initialized) f2f606c41 Merge pull request #677 from moneromooo-monero/foundAt ba629aded Simplify some code based on already checked values a5317986d Merge pull request #668 from muflihun/develop a0e1b5fad release a6477e2bb up 1f78ad898 Merge pull request #667 from muflihun/develop f01c1f8b0 removed message 45b360b20 Ignore sigint 680aeecdd Fixes #666 Set log level from custom message if available d47e10aec Fixing Readme for the right CustomFormatSpecifier signature 7645a4285 Add Emscripten detection, with test modifications 66a3a8741 Merge pull request #630 from muflihun/develop 1ebc9bbc8 update to release 8092189b3 Merge pull request #629 from muflihun/develop 094e4ab92 closes #580 conditional global lock dd8427200 Merge pull request #627 from muflihun/develop 99534e8c3 node binding version 92b81c8df Merge pull request #626 from muflihun/develop f0d0a71b7 Merge pull request #624 from adah1972/file_rolling_at_flush 56876a601 9.96.3 f788ff626 removed attr for gcc b96d4895f closes #620 Unused warnings fixed 2257b7533 null device logging 6af205d56 minor fix demangler 8d30366ec minor fix demangler 8eabcc37f Fix two wrong uses of "it's". 4fd8d92be Update README. 5feb891bf Simplify File::getSizeOfFile. e763286e3 Validate file rolling at flush point. f508c0c21 Merge pull request #619 from muflihun/develop 3e4e2b484 release 430a317c4 Merge pull request #618 from muflihun/develop 9c30e18b9 release 9.96.2 ceae14673 nav to build matrix 2e35613f6 travis fix 044b4f56c updated to use unordered_map closes #611 35eebba97 introduced new constructor for writer and dispatcher update 28612fcda u fd8fc502f updated travis 173358022 travis fix? c03b2c1d8 Merge pull request #616 from muflihun/develop 2ca71dd8e build matrix and sample 162b2ae17 trvis matrix e898d16fe use explicit declr ec43c830d potential wrapper for mutex e9dc1ecdb Merge pull request #615 from muflihun/develop a8b0bb016 update fix a7b9d6533 Merge pull request #614 from muflihun/develop ac1a71c33 9.96.1 release 251daa2e0 Two loggers writing to same file is undefined behaviour #613 89f61e588 Merge pull request #612 from muflihun/develop d40e8a020 Update README.md b443218a7 Update network-logger.cpp f5fe6c5f8 added send to network sample in README 6efc49142 Merge pull request #610 from muflihun/develop ee37c5c64 Update ACKNOWLEDGEMENTS.md 05bdfb0af release 9.96.0 fb67e3a3d Disable log file *initially* when using ELPP_NO_LOG_TO_FILE, to be consistent with documentation c1b128561 Generate and install a pkg-config file 193ea41a0 ack file 0da103b4e ack file 4442da152 respect MaxLogFileSize setting even when ELPP_NO_DEFAULT_LOG_FILE is set see PR #593 96919358c updated changelog 2614f8965 reformatting using astyle 2104884b3 license author joint 7679ace72 Potential deadlocks in extreme edge case - closes #609 5fd54a0dd Merge pull request #607 from muflihun/develop c06db0fa9 release b243df560 v9.95.4 01d12bdf5 made buildTimeInfo for use c6effe23e closes #606 for Writer b218fd3f3 closes #606 reserveCustomFormatSpecifiers e4931683b install cmake on travis ci 717d9607e update readme closes #585 b2ea92809 update changelog eb8ff3047 fix buffer underflow in getBashOutput 32ccda720 Issue #590: clarify usage of configuration macros a58288b4a updated year in license b7b4cbf8d Merge pull request #576 from muflihun/develop e04834d11 update release 049b242d4 Update MESSAGE.md e3f930ce1 Update MESSAGE.md 74ac78557 Update MESSAGE.md 4e5bc7086 Update MESSAGE.md cdf4875c6 Update MESSAGE.md 68b001956 msg 5b98f3ab0 Multithreading issue fixed raised from last release at log builder 11904e5ea Merge pull request #575 from muflihun/develop 5e4566e8b final release for 9.95.2 2990547dc Merge pull request #574 from muflihun/develop f197960e2 refix the failed release ba04082a3 Merge pull request #573 from muflihun/develop 417fa5ed9 9.95.1 release 7dcf83ebc closes #572 fixed printf like logging with thread safety 4286561b9 update e36f8663a fixed msg (see PR #568) 699c12ed9 closes #571 Removed global lock at dispatch 1a3d09bb2 Update README.md 1b515f9e8 up 78d630cbd updated sample 614608af1 Update README.md 3f6dd3e04 old gcc 9a171b4b6 Update README.md 0680b6dbb aix icon 89e37660b another updaet 9d2e024eb Added support for aix (thanks to apollo13) 33bc75ed9 closes #563 kFreeBSD fix c4ec767e6 change cmake to 2.8.7 850ea2a9f Merge pull request #559 from muflihun/develop f33a6239e Update README.md git-subtree-dir: vendor/github.com/muflihun/easyloggingpp git-subtree-split: 49da71da884d1e756a51df617437b87071c2b1a7
This commit is contained in:
parent
e405efee07
commit
b353ce4b9d
1
.github/FUNDING.yml
vendored
Normal file
1
.github/FUNDING.yml
vendored
Normal file
@ -0,0 +1 @@
|
||||
custom: https://amrayn.com/donate,https://www.paypal.me/mkhan3189
|
2
.gitignore
vendored
2
.gitignore
vendored
@ -6,4 +6,4 @@ release.info
|
||||
bin/*
|
||||
logs/*
|
||||
experiments/*
|
||||
CMakeLists.txt.user
|
||||
CMakeLists.txt.user*
|
||||
|
71
.travis.yml
71
.travis.yml
@ -1,11 +1,72 @@
|
||||
language: cpp
|
||||
compiler:
|
||||
- gcc
|
||||
os: linux
|
||||
dist: trusty
|
||||
matrix:
|
||||
include:
|
||||
# - os: linux
|
||||
# dist: trusty
|
||||
# compiler: clang
|
||||
# before_install:
|
||||
# - sudo add-apt-repository ppa:kubuntu-ppa/backports -y
|
||||
# - sudo apt-get -qq update
|
||||
# - sudo apt-get install -y libgtest-dev valgrind cmake
|
||||
# - sudo apt-get install --only-upgrade cmake
|
||||
# - sudo wget https://github.com/google/googletest/archive/release-1.7.0.tar.gz
|
||||
# - sudo tar xf release-1.7.0.tar.gz
|
||||
# - cd googletest-release-1.7.0
|
||||
# - sudo cmake -DBUILD_SHARED_LIBS=ON .
|
||||
# - sudo make
|
||||
# - sudo cp -a include/gtest /usr/include
|
||||
# - sudo cp -a libgtest_main.so libgtest.so /usr/lib/
|
||||
# - g++ -v
|
||||
|
||||
- os: linux
|
||||
dist: trusty
|
||||
compiler: gcc
|
||||
env:
|
||||
- COMPILER=g++-4.8
|
||||
addons:
|
||||
apt:
|
||||
sources: ['ubuntu-toolchain-r-test']
|
||||
packages: [g++-4.8, valgrind]
|
||||
- os: linux
|
||||
dist: trusty
|
||||
compiler: gcc
|
||||
env:
|
||||
- COMPILER=g++-4.9
|
||||
addons:
|
||||
apt:
|
||||
sources: ['ubuntu-toolchain-r-test']
|
||||
packages: [g++-4.9, valgrind]
|
||||
- os: linux
|
||||
dist: trusty
|
||||
compiler: gcc
|
||||
env:
|
||||
- COMPILER=g++-5
|
||||
addons:
|
||||
apt:
|
||||
sources: ['ubuntu-toolchain-r-test']
|
||||
packages: [g++-5, valgrind]
|
||||
- os: linux
|
||||
dist: trusty
|
||||
compiler: gcc
|
||||
env:
|
||||
- COMPILER=g++-6
|
||||
addons:
|
||||
apt:
|
||||
sources: ['ubuntu-toolchain-r-test']
|
||||
packages: [g++-6, valgrind]
|
||||
- os: linux
|
||||
dist: trusty
|
||||
compiler: gcc
|
||||
env:
|
||||
- COMPILER=g++-7
|
||||
addons:
|
||||
apt:
|
||||
sources: ['ubuntu-toolchain-r-test']
|
||||
packages: [g++-7, valgrind]
|
||||
|
||||
before_install:
|
||||
- sudo apt-get -qq update
|
||||
- sudo apt-get install -y libgtest-dev valgrind
|
||||
- sudo apt-get install -y libgtest-dev valgrind cmake
|
||||
- sudo wget https://github.com/google/googletest/archive/release-1.7.0.tar.gz
|
||||
- sudo tar xf release-1.7.0.tar.gz
|
||||
- cd googletest-release-1.7.0
|
||||
|
15
ACKNOWLEDGEMENTS.md
Normal file
15
ACKNOWLEDGEMENTS.md
Normal file
@ -0,0 +1,15 @@
|
||||
# Acknowledgements
|
||||
This file contains list of contributors and acknowledgement of their efforts in making this library better especially by making acceptable code changes.
|
||||
|
||||
If we have missed your name please feel free to add it with contribution link.
|
||||
|
||||
| **Github User** | **Contribution** |
|
||||
|--------------------------------------|----------------------------------|
|
||||
| [@aparajita](https://github.com/aparajita) | [Separated out .h and .cc file](https://github.com/amrayn/easyloggingpp/pulls?q=is%3Apr+author%3Aaparajita) |
|
||||
| [@adah1972](https://github.com/adah1972) | [A lot of contributions](https://github.com/amrayn/easyloggingpp/pulls?q=is%3Apr+author%3Aadah1972) |
|
||||
| [@miguelmartin75](https://github.com/miguelmartin75) | [Issue #11](https://github.com/amrayn/easyloggingpp/issues/11), [PR #16](https://github.com/amrayn/easyloggingpp/pull/16) |
|
||||
| [@moneromooo-monero](https://github.com/moneromooo-monero) | [A lot of contributions](https://github.com/amrayn/easyloggingpp/pulls?q=is%3Apr+author%3Amoneromooo-monero)|
|
||||
| [@MonsieurNicolas](https://github.com/MonsieurNicolas) | [PR #593](https://github.com/amrayn/easyloggingpp/pull/593) |
|
||||
| [@acowley](https://github.com/acowley) | [PR #593](https://github.com/amrayn/easyloggingpp/pull/577) |
|
||||
| [@rggjan](https://github.com/rggjan) | [PR 561](https://github.com/amrayn/easyloggingpp/pull/561) |
|
||||
| [@sgtcodfish](https://github.com/sgtcodfish) | Support for emscripten |
|
79
CHANGELOG.md
79
CHANGELOG.md
@ -1,14 +1,83 @@
|
||||
# Change Log
|
||||
|
||||
## [9.96.7] - 24-11-2018
|
||||
- Adds support for compiling easyloggingpp using Emscripten. This allows the library to be compiled into JavaScript or WebAssembly and run in the browser while logging to the browser's JavaScript console.
|
||||
|
||||
## [9.96.6] - 24-11-2018
|
||||
- Storage constructor (indirectly) attempts to access elStorage before it's initialized (issue #660) (@Barteks2x)
|
||||
- Fixed unused variable warning while build without performance logging feature (@wrgcpp)
|
||||
- Updated license
|
||||
|
||||
## [9.96.5] - 07-09-2018
|
||||
### Fixes
|
||||
- Check for level enabled when using custom log message (Advanced) (issue #666)
|
||||
- Ignore interruption signal crash log
|
||||
|
||||
## [9.96.4] - 03-04-2018
|
||||
### Fixes
|
||||
- Fixes seg fault with global lock (issue #580)
|
||||
|
||||
## [9.96.3] - 01-04-2018
|
||||
### Fixes
|
||||
- Demangling in GCC fixed
|
||||
- `ELPP_NO_DEFAULT_LOG_FILE` now logs to null device on major platforms (windows and unix)
|
||||
- Fixes unused warnings for constants
|
||||
|
||||
## [9.96.2] - 27-02-2018
|
||||
### Updates
|
||||
- Dispatcher now passes in pointer to log message instead of creating on the fly
|
||||
- Introduced new constructor for `Writer` for advanced usage (see amrayn/residue)
|
||||
- Use `std::unordered_map` for memory management instead of `std::map` issue #611
|
||||
|
||||
## [9.96.1] - 23-02-2018
|
||||
### Fixes
|
||||
- Two loggers writing to same file is undefined behaviour #613
|
||||
|
||||
## [9.96.0] - 14-02-2018
|
||||
### Fixes
|
||||
- Potential deadlocks in extreme edge case #609
|
||||
- Respect `MaxLogFileSize` setting even when `ELPP_NO_DEFAULT_LOG_FILE` is set (@MonsieurNicolas)
|
||||
- Disable log file **initially** when using `ELPP_NO_LOG_TO_FILE`, to be consistent with documentation (@rggjan)
|
||||
|
||||
### Updates
|
||||
- `el::Storage` no longer contains locks as it should be
|
||||
- Reformatted both files with `astyle`
|
||||
- License text updated
|
||||
|
||||
### Added
|
||||
- Install a pkg-config `.pc` file (@acowley)
|
||||
|
||||
## [9.95.4] - 10-02-2018
|
||||
### Fixes
|
||||
- Fix documentation (see PR#597)
|
||||
- Fix buffer underflow in getBashOutput (see PR#596)
|
||||
|
||||
### Updates
|
||||
- Added new function `Helpers::reserveCustomFormatSpecifier` (see #606)
|
||||
- Made `DateTime::buildTimeInfo` public for use
|
||||
|
||||
## [9.95.3] - 13-10-2017
|
||||
### Fixes
|
||||
- Multithreading issue fixed raised from last release at log builder
|
||||
|
||||
## [9.95.2] - 12-06-2017
|
||||
### Fixes
|
||||
- Build fix for kFreeBSD as suggested in issue #563
|
||||
- Fixed issue with deadlock on dispatch (see #571)
|
||||
- Fixed printf like logging with thread safety (see #572)
|
||||
|
||||
### Updates
|
||||
- Added support for AIX (thanks to @apollo13)
|
||||
|
||||
## [9.95.0] - 02-08-2017
|
||||
### Added
|
||||
- Added NetBSD as unix [coypoop](https://github.com/muflihun/easyloggingpp/pull/548/commits)
|
||||
- Added NetBSD as unix [coypoop](https://github.com/amrayn/easyloggingpp/pull/548/commits)
|
||||
- Ignore `NDEBUG` or `_DEBUG` to determine whether debug logs should be enabled or not. Use `ELPP_DISABLE_DEBUG_LOGS`
|
||||
|
||||
### Fixes
|
||||
- Fix compile when `_USE_32_BIT_TIME_T` defined [gggin](https://github.com/muflihun/easyloggingpp/pull/542/files)
|
||||
- Fix invalid usage of safeDelete which can cause an error with valgrind [Touyote](https://github.com/muflihun/easyloggingpp/pull/544/files)
|
||||
- Add code to ensure no nullptr references [tepperly](https://github.com/muflihun/easyloggingpp/pull/512/files)
|
||||
- Fix compile when `_USE_32_BIT_TIME_T` defined [gggin](https://github.com/amrayn/easyloggingpp/pull/542/files)
|
||||
- Fix invalid usage of safeDelete which can cause an error with valgrind [Touyote](https://github.com/amrayn/easyloggingpp/pull/544/files)
|
||||
- Add code to ensure no nullptr references [tepperly](https://github.com/amrayn/easyloggingpp/pull/512/files)
|
||||
|
||||
## [9.94.2] - 12-04-2017
|
||||
### Added
|
||||
@ -42,4 +111,4 @@
|
||||
- Custom format specifier now has to return `std::string` instead
|
||||
- Merged `thread_name` with `thread` if thread name is available it's used otherwise ID is displayed
|
||||
|
||||
For older versions please refer to [https://github.com/muflihun/easyloggingpp/tree/master/doc](https://github.com/muflihun/easyloggingpp/tree/master/doc)
|
||||
For older versions please refer to [https://github.com/amrayn/easyloggingpp/tree/master/doc](https://github.com/amrayn/easyloggingpp/tree/master/doc)
|
||||
|
@ -1,4 +1,4 @@
|
||||
cmake_minimum_required(VERSION 2.8.12)
|
||||
cmake_minimum_required(VERSION 2.8.7)
|
||||
|
||||
project(Easyloggingpp CXX)
|
||||
|
||||
@ -26,11 +26,12 @@ option(build_static_lib "Build easyloggingpp as a static library" OFF)
|
||||
option(lib_utc_datetime "Build library with UTC date/time logging" OFF)
|
||||
|
||||
set(ELPP_MAJOR_VERSION "9")
|
||||
set(ELPP_MINOR_VERSION "95")
|
||||
set(ELPP_PATCH_VERSION "0")
|
||||
set(ELPP_MINOR_VERSION "96")
|
||||
set(ELPP_PATCH_VERSION "7")
|
||||
set(ELPP_VERSION_STRING "${ELPP_MAJOR_VERSION}.${ELPP_MINOR_VERSION}.${ELPP_PATCH_VERSION}")
|
||||
|
||||
set(ELPP_INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/include" CACHE PATH "The directory the headers are installed in")
|
||||
set(ELPP_PKGCONFIG_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/share/pkgconfig" CACHE PATH "Installation directory for pkgconfig (.pc) files")
|
||||
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
|
||||
|
||||
@ -40,6 +41,17 @@ install(FILES
|
||||
DESTINATION "${ELPP_INCLUDE_INSTALL_DIR}"
|
||||
COMPONENT dev)
|
||||
|
||||
configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/easyloggingpp.pc.cmakein
|
||||
${CMAKE_CURRENT_BINARY_DIR}/easyloggingpp.pc @ONLY)
|
||||
|
||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/easyloggingpp.pc DESTINATION "${ELPP_PKGCONFIG_INSTALL_DIR}")
|
||||
|
||||
include(CheckIncludeFileCXX)
|
||||
check_include_file_cxx("execinfo.h" HAVE_EXECINFO)
|
||||
if (HAVE_EXECINFO)
|
||||
add_definitions(-DHAVE_EXECINFO)
|
||||
endif()
|
||||
|
||||
if (build_static_lib)
|
||||
if (lib_utc_datetime)
|
||||
add_definitions(-DELPP_UTC_DATETIME)
|
||||
@ -47,6 +59,7 @@ if (build_static_lib)
|
||||
|
||||
require_cpp11()
|
||||
add_library(easyloggingpp STATIC src/easylogging++.cc)
|
||||
set_property(TARGET easyloggingpp PROPERTY POSITION_INDEPENDENT_CODE ON)
|
||||
|
||||
install(TARGETS
|
||||
easyloggingpp
|
||||
@ -68,6 +81,10 @@ if (test)
|
||||
|
||||
enable_testing()
|
||||
|
||||
if (EMSCRIPTEN)
|
||||
set(CMAKE_EXE_LINKER_FLAGS "-O2 -s TOTAL_MEMORY=134217728")
|
||||
endif()
|
||||
|
||||
add_executable(easyloggingpp-unit-tests
|
||||
src/easylogging++.cc
|
||||
test/main.cc
|
||||
|
@ -1,9 +1,10 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2017 muflihun.com
|
||||
Copyright (c) 2012-2018 Amrayn Web Services
|
||||
Copyright (c) 2012-2018 @abumusamq
|
||||
|
||||
https://github.com/muflihun/
|
||||
https://muflihun.github.io
|
||||
https://github.com/amrayn/
|
||||
https://amrayn.com
|
||||
https://muflihun.com
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
404
README.md
404
README.md
@ -1,39 +1,38 @@
|
||||
بسم الله الرَّحْمَنِ الرَّحِيمِ
|
||||
|
||||
<p align="center">
|
||||
﷽
|
||||
</p>
|
||||
|
||||
![banner]
|
||||
|
||||
> **Manual For v9.95.0**
|
||||
> **Manual For v9.96.7**
|
||||
|
||||
[](https://travis-ci.org/muflihun/easyloggingpp) (`develop`)
|
||||
[](#build-matrix)
|
||||
[](#build-matrix)
|
||||
[](https://ci.appveyor.com/project/abumusamq/easyloggingpp-node)
|
||||
|
||||
[](https://travis-ci.org/muflihun/easyloggingpp) (`master`)
|
||||
[](https://github.com/amrayn/easyloggingpp-node/releases/latest)
|
||||
[](https://www.npmjs.com/package/easyloggingpp)
|
||||
|
||||
[](https://github.com/muflihun/easyloggingpp/releases/latest)
|
||||
[](https://github.com/amrayn/easyloggingpp/blob/master/LICENCE)
|
||||
[](https://github.com/amrayn/easyloggingpp/releases/latest)
|
||||
|
||||
[](http://www.conan.io/source/easyloggingpp/9.95.0/memsharded/testing)
|
||||
[](https://amrayn.com/donate)
|
||||
|
||||
[](http://melpon.org/wandbox/permlink/rwDXGcnP1IoCKXrJ)
|
||||
|
||||
[](https://github.com/muflihun/easyloggingpp/blob/master/LICENCE)
|
||||
|
||||
[](https://www.paypal.me/MuflihunDotCom/25)
|
||||
|
||||
[](https://github.com/muflihun/easyloggingpp/releases/latest)
|
||||
#### Looking for maintainers!!
|
||||
|
||||
### Quick Links
|
||||
|
||||
[![download] Latest Release](https://github.com/muflihun/easyloggingpp/releases/latest)
|
||||
|
||||
[![download] Latest Release](https://github.com/amrayn/easyloggingpp/releases/latest)
|
||||
|
||||
[![notes] Changelog](/CHANGELOG.md)
|
||||
|
||||
|
||||
[![samples] Samples](/samples)
|
||||
|
||||
---
|
||||
|
||||
### Table of Contents
|
||||
<pre>
|
||||
<a href="#introduction">Introduction</a>
|
||||
<a href="#overview">Overview</a>
|
||||
<a href="#why-yet-another-library">Why yet another library</a>
|
||||
<a href="#features-at-a-glance">Features at a glance</a>
|
||||
<a href="#getting-started">Getting Started</a>
|
||||
@ -64,7 +63,7 @@
|
||||
<a href="#network-logging">Network Logging</a>
|
||||
<a href="#verbose-logging">Verbose Logging</a>
|
||||
<a href="#basic-1">Basic</a>
|
||||
<a href="#conditional-and-occasional">Conditional and Occasional</a>
|
||||
<a href="#conditional-and-occasional-logging">Conditional and Occasional</a>
|
||||
<a href="#verbose-level">Verbose Level</a>
|
||||
<a href="#check-if-verbose-logging-is-on">Check If Verbose Logging Is On</a>
|
||||
<a href="#vmodule">VModule</a>
|
||||
@ -101,30 +100,33 @@
|
||||
<a href="#submitting-patches">Submitting Patches</a>
|
||||
<a href="#reporting-a-bug">Reporting a Bug</a>
|
||||
<a href="#compatibility">Compatibility</a>
|
||||
<a href="#build-matrix">Build Matrix</a>
|
||||
<a href="#licence">Licence</a>
|
||||
<a href="#disclaimer">Disclaimer</a>
|
||||
</pre>
|
||||
|
||||
# Introduction
|
||||
Easylogging++ is single header efficient logging library for C++ applications. It is extremely powerful, highly extendable and configurable to user's requirements. It provides ability to [write your own sinks](https://github.com/muflihun/easyloggingpp/tree/master/samples/send-to-network) (referred to as `LogDispatchCallback`). Currently used by hundreds of open-source projects.
|
||||
# Overview
|
||||
Easylogging++ is single header efficient logging library for C++ applications. It is extremely powerful, highly extendable and configurable to user's requirements. It provides ability to [write your own _sinks_](/samples/send-to-network) (via featured referred as `LogDispatchCallback`). This library is currently used by [hundreds of open-source projects on github](https://github.com/search?q=%22easylogging%2B%2B.h%22&type=Code&utf8=%E2%9C%93) and other open-source source control management sites.
|
||||
|
||||
This manual is for Easylogging++ v9.95.0. For other versions please refer to corresponding [release](https://github.com/muflihun/easyloggingpp/releases) on github.
|
||||
This manual is for Easylogging++ v9.96.7. For other versions please refer to corresponding [release](https://github.com/amrayn/easyloggingpp/releases) on github.
|
||||
|
||||
> You may also be interested in [Residue](https://github.com/amrayn/residue/) logging server.
|
||||
|
||||
[![top] Goto Top](#table-of-contents)
|
||||
|
||||
|
||||
### Why yet another library
|
||||
If you are working on a small utility or large project in C++, this library can be handy. Its based on single header and only requires to link to single source file. (Originally it was header-only and was changed to use source file in [issue #445](https://github.com/muflihun/easyloggingpp/issues/445). You can still use header-only in [v9.89](https://github.com/muflihun/easyloggingpp/releases/tag/9.89)).
|
||||
If you are working on a small utility or large project in C++, this library can be handy. Its based on single header and only requires to link to single source file. (Originally it was header-only and was changed to use source file in [issue #445](https://github.com/amrayn/easyloggingpp/issues/445). You can still use header-only in [v9.89](https://github.com/amrayn/easyloggingpp/releases/tag/9.89)).
|
||||
|
||||
This library has been designed with various thoughts in mind (i.e, portability, performance, usability, features and easy to setup).
|
||||
|
||||
Why yet another library? Well, answer is pretty straight forward, use it as you wrote it so you can fix issues (if any) as you go or raise them on github. In addition to that, I personally have not seen any logging library based on single-header with such a design where you can configure on the go, extend it to your needs and get fast performance. I have seen other single-header logging libraries for C++ but either they use external libraries, e.g, boost or Qt to support certain features like threading, regular expression or date etc. This library has everything built-in to prevent usage of external libraries, not that I don't like those libraries, in fact I love them, but because not all projects use these libraries, I couldn't take risk of depending on them.
|
||||
|
||||
[![top] Goto Top](#table-of-contents)
|
||||
|
||||
|
||||
### Features at a glance
|
||||
Easylogging++ is feature-rich containing many features that both typical and advanced developer will require while writing a software;
|
||||
* [Highly configurable](#configuration)
|
||||
* [Extendable](#log-dispatch-callback)
|
||||
* [Extendable](#extending-library)
|
||||
* Extremely fast
|
||||
* [Thread](#multi-threading) and type safe
|
||||
* [Cross-platform](#compatibility)
|
||||
@ -141,15 +143,15 @@ Easylogging++ is feature-rich containing many features that both typical and adv
|
||||
* [And many more...](#extra-features)
|
||||
|
||||
[![top] Goto Top](#table-of-contents)
|
||||
|
||||
|
||||
# Getting Started
|
||||
### Download
|
||||
Download latest version from [Latest Release](https://github.com/muflihun/easyloggingpp/releases/latest)
|
||||
Download latest version from [Latest Release](https://github.com/amrayn/easyloggingpp/releases/latest)
|
||||
|
||||
For other releases, please visit [releases page](https://github.com/muflihun/easyloggingpp/releases). If you application does not support C++11, please consider using [v8.91](https://github.com/muflihun/easyloggingpp/tree/v8.91). This is stable version for C++98 and C++03, just lack some features.
|
||||
For other releases, please visit [releases page](https://github.com/amrayn/easyloggingpp/releases). If you application does not support C++11, please consider using [v8.91](https://github.com/amrayn/easyloggingpp/tree/v8.91). This is stable version for C++98 and C++03, just lack some features.
|
||||
|
||||
[![top] Goto Top](#table-of-contents)
|
||||
|
||||
|
||||
### Quick Start
|
||||
In order to get started with Easylogging++, you can follow three easy steps:
|
||||
* Download latest version
|
||||
@ -173,7 +175,7 @@ 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.
|
||||
That simple! Please note that `INITIALIZE_EASYLOGGINGPP` should be used once and once-only otherwise you will end up getting compilation errors. This is the definition of 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)
|
||||
If you want to install this header system-wide, you can do so via:
|
||||
@ -189,12 +191,23 @@ make install
|
||||
Following options are supported by Easylogging++ cmake and you can turn these options on using `-D<option>=ON`
|
||||
|
||||
* `lib_utc_datetime` - Defines `ELPP_UTC_DATETIME`
|
||||
* `build_static_lib` - Builds static library for Easylogging++
|
||||
* `build_static_lib` - Builds static library for Easylogging++
|
||||
|
||||
With that said, you will still need `easylogging++.cc` file in order to compile. For header only, please check [v9.89](https://github.com/muflihun/easyloggingpp/releases/tag/9.89) and lower.
|
||||
With that said, you will still need `easylogging++.cc` file in order to compile. For header only, please check [v9.89](https://github.com/amrayn/easyloggingpp/releases/tag/9.89) and lower.
|
||||
|
||||
Alternatively, you can download and install easyloggingpp using the [vcpkg](https://github.com/Microsoft/vcpkg/) dependency manager:
|
||||
|
||||
git clone https://github.com/Microsoft/vcpkg.git
|
||||
cd vcpkg
|
||||
./bootstrap-vcpkg.sh
|
||||
./vcpkg integrate install
|
||||
./vcpkg install easyloggingpp
|
||||
|
||||
The easyloggingpp port in vcpkg is kept up to date by Microsoft team members and community contributors.
|
||||
If the version is out of date, please [create an issue or pull request](https://github.com/Microsoft/vcpkg) on the vcpkg repository.
|
||||
|
||||
[![top] Goto Top](#table-of-contents)
|
||||
|
||||
|
||||
### Setting Application Arguments
|
||||
It is always recommended to pass application arguments to Easylogging++. Some features of Easylogging++ require you to set application arguments, e.g, verbose logging to set verbose level or vmodules (explained later). In order to do that you can use helper macro or helper class;
|
||||
|
||||
@ -205,7 +218,7 @@ int main(int argc, char* argv[]) {
|
||||
}
|
||||
```
|
||||
[![top] Goto Top](#table-of-contents)
|
||||
|
||||
|
||||
# Configuration
|
||||
### Level
|
||||
In order to start configuring your logging library, you must understand severity levels. Easylogging++ deliberately does not use hierarchical logging in order to fully control what's enabled and what's not. That being said, there is still option to use hierarchical logging using `LoggingFlag::HierarchicalLogging`. Easylogging++ has following levels (ordered for hierarchical levels)
|
||||
@ -223,7 +236,7 @@ In order to start configuring your logging library, you must understand severity
|
||||
| Unknown | Only applicable to hierarchical logging and is used to turn off logging completely. |
|
||||
|
||||
[![top] Goto Top](#table-of-contents)
|
||||
|
||||
|
||||
### Configure
|
||||
Easylogging++ is easy to configure. There are three possible ways to do so,
|
||||
* Using configuration file
|
||||
@ -252,7 +265,7 @@ Following table contains configurations supported by configuration file.
|
||||
| `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 |
|
||||
|
||||
|
||||
|
||||
Please do not use double-quotes anywhere in comment, you might end up in unexpected behaviour.
|
||||
|
||||
@ -272,7 +285,7 @@ Sample Configuration File
|
||||
FORMAT = "%datetime{%d/%M} %func %msg"
|
||||
```
|
||||
|
||||
##### Explanation
|
||||
##### Explanation
|
||||
Configuration file contents in above sample is straightforward. We start with `GLOBAL` level in order to override all the levels. Any explicitly defined subsequent level will override configuration from `GLOBAL`. For example, all the levels except for `DEBUG` have the same format, i.e, datetime and log message. For `DEBUG` level, we have only date (with day and month), source function and log message. The rest of configurations for `DEBUG` are used from `GLOBAL`. Also, notice `{%d/%M}` in `DEBUG` format above, if you do not specify date format, default format is used. Default values of date/time is `%d/%M/%Y %h:%m:%s,%g` For more information on these format specifiers, please refer to [Date/Time Format Specifier](#datetime-format-specifiers) section below
|
||||
|
||||
##### Usage
|
||||
@ -295,7 +308,7 @@ int main(int argc, const char** argv) {
|
||||
> Your configuration file can be converted to `el::Configurations` object (using constructor) that can be used where ever it is needed (like in above example).
|
||||
|
||||
[![top] Goto Top](#table-of-contents)
|
||||
|
||||
|
||||
#### Using el::Configurations Class
|
||||
You can set configurations or reset configurations;
|
||||
```c++
|
||||
@ -307,7 +320,7 @@ int main(int argc, const char** argv) {
|
||||
el::Configurations defaultConf;
|
||||
defaultConf.setToDefault();
|
||||
// Values are always std::string
|
||||
defaultConf.set(el::Level::Info,
|
||||
defaultConf.set(el::Level::Info,
|
||||
el::ConfigurationType::Format, "%datetime %level %msg");
|
||||
// default logger uses default configurations
|
||||
el::Loggers::reconfigureLogger("default", defaultConf);
|
||||
@ -323,7 +336,7 @@ int main(int argc, const char** argv) {
|
||||
> Configuration just needs to be set once. If you are happy with default configuration, you may use it as well.
|
||||
|
||||
[![top] Goto Top](#table-of-contents)
|
||||
|
||||
|
||||
#### Using In line Configurations
|
||||
Inline configuration means you can set configurations in `std::string` but make sure you add all the new line characters etc. This is not recommended because it's always messy.
|
||||
```c++
|
||||
@ -335,12 +348,12 @@ c.parseFromText("*GLOBAL:\n FORMAT = %level %msg");
|
||||
> Above code only sets Configurations object, you still need to re-configure logger/s using this configurations.
|
||||
|
||||
[![top] Goto Top](#table-of-contents)
|
||||
|
||||
|
||||
### Default Configurations
|
||||
If you wish to have a configuration for existing and future loggers, you can use `el::Loggers::setDefaultConfigurations(el::Configurations& configurations, bool configureExistingLoggers = false)`. This is useful when you are working on fairly large scale, or using a third-party library that is already using Easylogging++. Any newly created logger will use default configurations. If you wish to configure existing loggers as well, you can set second argument to `true` (it defaults to `false`).
|
||||
|
||||
[![top] Goto Top](#table-of-contents)
|
||||
|
||||
|
||||
### Global Configurations
|
||||
`Level::Global` is nothing to do with global configurations, it is concept where you can register configurations for all/or some loggers and even register new loggers using configuration file. Syntax of configuration file is:
|
||||
```
|
||||
@ -365,7 +378,7 @@ int main(void) {
|
||||
Please note, it is not possible to register new logger using global configuration without defining its configuration. You must define at least single configuration. Other ways to register loggers are discussed in [Logging](#logging) section below.
|
||||
|
||||
[![top] Goto Top](#table-of-contents)
|
||||
|
||||
|
||||
### Logging Format Specifiers
|
||||
You can customize format of logging using following specifiers:
|
||||
|
||||
@ -388,10 +401,10 @@ You can customize format of logging using following specifiers:
|
||||
| `%msg` | Actual log message |
|
||||
| `%` | Escape character (e.g, %%level will write %level) |
|
||||
|
||||
* Subject to compiler's availability of certain macros, e.g, `__LINE__`, `__FILE__` etc
|
||||
* Subject to compiler's availability of certain macros, e.g, `__LINE__`, `__FILE__` etc
|
||||
|
||||
[![top] Goto Top](#table-of-contents)
|
||||
|
||||
|
||||
### Date/Time Format Specifiers
|
||||
You can customize date/time format using following specifiers
|
||||
|
||||
@ -422,7 +435,7 @@ Please note, date/time is limited to `30` characters at most.
|
||||
You can also specify your own format specifiers. In order to do that you can use `el::Helpers::installCustomFormatSpecifier`. A perfect example is `%ip_addr` for TCP server application;
|
||||
|
||||
```C++
|
||||
const char* getIp(void) {
|
||||
const char* getIp(const el::LogMessage*) {
|
||||
return "192.168.1.1";
|
||||
}
|
||||
|
||||
@ -435,17 +448,17 @@ int main(void) {
|
||||
```
|
||||
|
||||
[![top] Goto Top](#table-of-contents)
|
||||
|
||||
###Logging Flags
|
||||
|
||||
### Logging Flags
|
||||
Form some parts of logging you can set logging flags; here are flags supported:
|
||||
|
||||
| Flag | Description |
|
||||
|--------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| `NewLineForContainer (1)` | Makes sure we have new line for each container log entry |
|
||||
| `AllowVerboseIfModuleNotSpecified (2)` | Makes sure if -vmodule is used and does not specifies a module, then verbose logging is allowed via that module. Say param was -vmodule=main*=3 and a verbose log is being written from a file called something.cpp then if this flag is enabled, log will be written otherwise it will be disallowed. Note: having this defeats purpose of -vmodule |
|
||||
| `LogDetailedCrashReason (4)` | When handling crashes by default, detailed crash reason will be logged as well (Disabled by default) ([issue #90](https://github.com/muflihun/easyloggingpp/issues/90)) |
|
||||
| `DisableApplicationAbortOnFatalLog (8)` | Allows to disable application abortion when logged using FATAL level. Note that this does not apply to default crash handlers as application should be aborted after crash signal is handled. (Not added by default) ([issue #119](https://github.com/muflihun/easyloggingpp/issues/119)) |
|
||||
| `ImmediateFlush (16)` | Flushes log with every log-entry (performance sensative) - Disabled by default |
|
||||
| `LogDetailedCrashReason (4)` | When handling crashes by default, detailed crash reason will be logged as well (Disabled by default) ([issue #90](https://github.com/amrayn/easyloggingpp/issues/90)) |
|
||||
| `DisableApplicationAbortOnFatalLog (8)` | Allows to disable application abortion when logged using FATAL level. Note that this does not apply to default crash handlers as application should be aborted after crash signal is handled. (Not added by default) ([issue #119](https://github.com/amrayn/easyloggingpp/issues/119)) |
|
||||
| `ImmediateFlush (16)` | Flushes log with every log-entry (performance sensitive) - Disabled by default |
|
||||
| `StrictLogFileSizeCheck (32)` | Makes sure log file size is checked with every log |
|
||||
| `ColoredTerminalOutput (64)` | Terminal output will be colorful if supported by terminal. |
|
||||
| `MultiLoggerSupport (128)` | Enables support for using multiple loggers to log single message. (E.g, `CLOG(INFO, "default", "network") << This will be logged using default and network loggers;`) |
|
||||
@ -455,7 +468,8 @@ Form some parts of logging you can set logging flags; here are flags supported:
|
||||
| `HierarchicalLogging (2048)` | Enables hierarchical logging. This is not applicable to verbose logging.|
|
||||
| `CreateLoggerAutomatically (4096)` | Creates logger automatically when not available. |
|
||||
| `AutoSpacing (8192)` | Automatically adds spaces. E.g, `LOG(INFO) << "DODGE" << "THIS!";` will output "DODGE THIS!"|
|
||||
| `FixedTimeFormat (16384)` | Applicable to performace tracking only - this prevents formatting time. E.g, `1001 ms` will be logged as is, instead of formatting it as `1.01 sec`|
|
||||
| `FixedTimeFormat (16384)` | Applicable to performance tracking only - this prevents formatting time. E.g, `1001 ms` will be logged as is, instead of formatting it as `1.01 sec`|
|
||||
| `IgnoreSigInt (32768)` | When application crashes ignore Interruption signal |
|
||||
|
||||
You can set/unset these flags by using static `el::Loggers::addFlag` and `el::Loggers::removeFlag`. You can check to see if certain flag is available by using `el::Loggers::hasFlag`, all these functions take strongly-typed enum `el::LoggingFlag`
|
||||
|
||||
@ -482,7 +496,11 @@ Following table will explain all command line arguments that you may use to defi
|
||||
### Configuration Macros
|
||||
Some of logging options can be set by macros, this is a thoughtful decision, for example if we have `ELPP_THREAD_SAFE` defined, all the thread-safe functionalities are enabled otherwise disabled (making sure over-head of thread-safety goes with it). To make it easy to remember and prevent possible conflicts, all the macros start with `ELPP_`
|
||||
|
||||
NOTE: All the macros either need to be defined before `#include "easylogging++"` - but this gets hard and unreadable if project is getting bigger so we recommend you define all these macros using `-D` option of compiler, for example in case of `g++` you will do `g++ source.cpp ... -DELPP_SYSLOG -DELPP_THREAD_SAFE ...`
|
||||
**NOTE:** All the macros can be defined in one of the following ways:
|
||||
|
||||
1. Define macros using `-D` option of compiler, for example in case of `g++` you will do `g++ source.cpp ... -DELPP_SYSLOG -DELPP_THREAD_SAFE ...` (**recommended way**)
|
||||
|
||||
2. Define macros inside `"easylogging++.h"` ([defining macros in other files won't work](https://github.com/amrayn/easyloggingpp/issues/590#issuecomment-346753951))
|
||||
|
||||
| Macro Name | Description |
|
||||
|------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
@ -500,10 +518,10 @@ NOTE: All the macros either need to be defined before `#include "easylogging++"`
|
||||
| `ELPP_DISABLE_FATAL_LOGS` | Disables fatal logs - (preprocessing) |
|
||||
| `ELPP_DISABLE_VERBOSE_LOGS` | Disables verbose logs - (preprocessing) |
|
||||
| `ELPP_DISABLE_TRACE_LOGS` | Disables trace logs - (preprocessing) |
|
||||
| `ELPP_FORCE_ENV_VAR_FROM_BASH` | If environment variable could not be found, force using alternative bash command to find value, e.g, `whoami` for username. (DO NOT USE THIS MACRO WITH `LD_PRELOAD` FOR LIBRARIES THAT ARE ALREADY USING Easylogging++ OR YOU WILL END UP IN STACK OVERFLOW FOR PROCESSES (`popen`) (see [issue #87](https://github.com/muflihun/easyloggingpp/issues/87) for details)) |
|
||||
| `ELPP_FORCE_ENV_VAR_FROM_BASH` | If environment variable could not be found, force using alternative bash command to find value, e.g, `whoami` for username. (DO NOT USE THIS MACRO WITH `LD_PRELOAD` FOR LIBRARIES THAT ARE ALREADY USING Easylogging++ OR YOU WILL END UP IN STACK OVERFLOW FOR PROCESSES (`popen`) (see [issue #87](https://github.com/amrayn/easyloggingpp/issues/87) for details)) |
|
||||
| `ELPP_DEFAULT_LOG_FILE` | Full filename where you want initial files to be created. You need to embed value of this macro with quotes, e.g, `-DELPP_DEFAULT_LOG_FILE='"logs/el.gtest.log"'` Note the double quotes inside single quotes, double quotes are the values for `const char*` and single quotes specifies value of macro |
|
||||
| `ELPP_NO_LOG_TO_FILE` | Disable logging to file initially|
|
||||
| `ELPP_NO_DEFAULT_LOG_FILE` | If you dont want to initialize library with default log file, define this macro. But be sure to configure your logger with propery log filename or you will end up getting heaps of errors when trying to log to file (and `TO_FILE` is configured to `true`) |
|
||||
| `ELPP_NO_DEFAULT_LOG_FILE` | If you dont want to initialize library with default log file, define this macro. This will log to null device for unix and windows. In other platforms you may get error and you will need to use `ELPP_DEFAULT_LOG_FILE`. (PR for other platform's null devices are most welcomed) |
|
||||
| `ELPP_FRESH_LOG_FILE` | Never appends log file whenever log file is created (Use with care as it may cause some unexpected result for some users) |
|
||||
| `ELPP_DEBUG_ERRORS` | If you wish to find out internal errors raised by Easylogging++ that can be because of configuration or something else, you can enable them by defining this macro. You will get your errors on standard output i.e, terminal or command prompt. |
|
||||
| `ELPP_DISABLE_CUSTOM_FORMAT_SPECIFIERS` | Forcefully disables custom format specifiers |
|
||||
@ -515,21 +533,22 @@ NOTE: All the macros either need to be defined before `#include "easylogging++"`
|
||||
| `ELPP_NO_CHECK_MACROS` | Do not define the *CHECK* macros |
|
||||
| `ELPP_NO_DEBUG_MACROS` | Do not define the *DEBUG* macros |
|
||||
| `ELPP_UTC_DATETIME` | Uses UTC time instead of local time (essentially uses `gmtime` instead of `localtime` and family functions)
|
||||
| `ELPP_NO_GLOBAL_LOCK` | Do not lock the whole storage on dispatch. This should be used with care. See [issue #580](https://github.com/amrayn/easyloggingpp/issues/580)|
|
||||
|
||||
[![top] Goto Top](#table-of-contents)
|
||||
|
||||
|
||||
### Reading Configurations
|
||||
If you wish to read configurations of certain logger, you can do so by using `typedConfigurations()` function in Logger class.
|
||||
```c++
|
||||
el::Logger* l = el::Loggers::getLogger("default");
|
||||
bool enabled = l->typedConfigurations()->enabled(el::Level::Info);
|
||||
// Or to read log format/pattern
|
||||
std::string format =
|
||||
std::string format =
|
||||
l->typedConfigurations()->logFormat(el::Level::Info).format();
|
||||
```
|
||||
|
||||
[![top] Goto Top](#table-of-contents)
|
||||
|
||||
|
||||
# Logging
|
||||
Logging in easylogging++ is done using collection of macros. This is to make it easier for user and to prevent them knowing about unnecessary greater details of how things are done.
|
||||
|
||||
@ -572,9 +591,9 @@ UpdateManager::UpdateManager {
|
||||
> You can also write logs by using `Logger` class directly. This feature is available on compilers that support variadic templates. You can explore more by looking at `samples/STL/logger-log-functions.cpp`.
|
||||
|
||||
[![top] Goto Top](#table-of-contents)
|
||||
|
||||
|
||||
### Conditional Logging
|
||||
Easylogging++ provides certain aspects of logging, one these aspects is conditional logging, i.e, log will be written only if certain condition fulfils. This comes very handy in some situations.
|
||||
Easylogging++ provides certain aspects of logging, one these aspects is conditional logging, i.e, log will be written only if certain condition fulfils. This comes very handy in some situations.
|
||||
Helper macros end with _IF;
|
||||
* `LOG_IF(condition, LEVEL)`
|
||||
* `CLOG_IF(condition, LEVEL, logger ID)`
|
||||
@ -591,7 +610,7 @@ CLOG_IF(true, INFO, "performance") << "Always logged (performance logger)"
|
||||
Same macros are available for verbose logging with `V` in the beginning, i.e, `VLOG_IF` and `CVLOG_IF`. see verbose logging section below for further information. You may have as complicated conditions as you want depending on your need.
|
||||
|
||||
[![top] Goto Top](#table-of-contents)
|
||||
|
||||
|
||||
### Occasional Logging
|
||||
Occasional logging is another useful aspect of logging with Easylogging++. This means a log will be written if it's hit certain times or part of certain times, e.g, every 10th hit or 100th hit or 2nd hit.
|
||||
Helper macros end with `_EVERY_N`;
|
||||
@ -624,14 +643,14 @@ for (int i = 1; i <= 100; ++i) {
|
||||
> Same versions of macros are available for `DEBUG` only mode, these macros start with `D` (for debug) followed by the same name. e.g, `DLOG` to log only in debug mode (i.e, when `_DEBUG` is defined or `NDEBUG` is undefined)
|
||||
|
||||
[![top] Goto Top](#table-of-contents)
|
||||
|
||||
|
||||
### `printf` Like Logging
|
||||
For compilers that support C++11's variadic templates, ability to log like "printf" is available. This is done by using `Logger` class. This feature is thread and type safe (as we do not use any macros like `LOG(INFO)` etc)
|
||||
|
||||
This is done in two steps:
|
||||
1. Pulling registered logger using `el::Loggers::getLogger(<logger_id>);`
|
||||
2. Using one of logging functions
|
||||
|
||||
|
||||
The only difference from `printf` is that logging using these functions require `%v` for each arg (This is for type-safety); instead of custom format specifiers. You can escape this by `%%v`
|
||||
|
||||
Following are various function signatures:
|
||||
@ -642,7 +661,7 @@ Following are various function signatures:
|
||||
* `fatal(const char*, const T&, const Args&...)`
|
||||
* `trace(const char*, const T&, const Args&...)`
|
||||
* `verbose(int vlevel, const char*, const T&, const Args&...)`
|
||||
|
||||
|
||||
#### Simple example:
|
||||
|
||||
```c++
|
||||
@ -676,7 +695,7 @@ Verbose logging is useful in every software to record more information than usua
|
||||
* `CVLOG(verbose-level, logger ID)`
|
||||
|
||||
[![top] Goto Top](#table-of-contents)
|
||||
|
||||
|
||||
#### Conditional and Occasional Logging
|
||||
Verbose logging also has conditional and occasional logging aspects i.e,
|
||||
* `VLOG_IF(condition, verbose-level)`
|
||||
@ -690,14 +709,14 @@ Verbose logging also has conditional and occasional logging aspects i.e,
|
||||
|
||||
[![top] Goto Top](#table-of-contents)
|
||||
|
||||
|
||||
|
||||
#### Verbose-Level
|
||||
Verbose level is level of verbosity that can have range of 1-9. Verbose level will not be active unless you either set application arguments for it. Please read through [Application Arguments](#application-arguments) section to understand more about verbose logging.
|
||||
|
||||
In order to change verbose level on the fly, please use `Loggers::setVerboseLevel(base::type::VerboseLevel)` aka `Loggers::setVerboseLevel(int)` function. (You can check current verbose level by `Loggers::verboseLevel()`
|
||||
|
||||
[![top] Goto Top](#table-of-contents)
|
||||
|
||||
|
||||
#### Check If Verbose Logging Is On
|
||||
You can use a macro `VLOG_IS_ON(verbose-level)` to check to see if certain logging is on for source file for specified verbose level. This returns boolean that you can embed into if condition.
|
||||
```c++
|
||||
@ -707,7 +726,7 @@ if (VLOG_IS_ON(2)) {
|
||||
```
|
||||
|
||||
[![top] Goto Top](#table-of-contents)
|
||||
|
||||
|
||||
#### VModule
|
||||
VModule is functionality for verbose logging (as mentioned in above table) where you can specify verbosity by modules/source file. Following are some examples with explanation; Any of vmodule below starts with `-vmodule=` and `LoggingFlag::DisableVModulesExtensions` flag not set. Vmodule can completely be disabled by adding flag `LoggingFlag::DisableVModules`
|
||||
|
||||
@ -728,7 +747,7 @@ Example with no `LoggingFlag::AllowVerboseIfModuleNotSpecified` flag;
|
||||
In order to change vmodules on the fly (instead of via command line args) - use `Loggers::setVModules(const char*)` where `const char*` represents the modules e.g, `main=3,parser*=4` (as per above example)
|
||||
|
||||
[![top] Goto Top](#table-of-contents)
|
||||
|
||||
|
||||
### Registering New Loggers
|
||||
Loggers are unique in logger repository by ID. You can register new logger the same way as you would get logger. Using `getLogger(.., ..)` from `el::Loggers` helper class. This function takes two params, first being ID and second being boolean (optional) to whether or not to register new logger if does not already exist and returns pointer to existing (or newly created) el::Logger class. This second param is optional and defaults to true. If you set it to false and logger does not exist already, it will return nullptr.
|
||||
|
||||
@ -740,7 +759,7 @@ By default, Easylogging++ registers three loggers (+ an internal logger);
|
||||
If you wish to register a new logger, say e.g, with ID `business`
|
||||
```c++
|
||||
el::Logger* businessLogger = el::Loggers::getLogger("business");
|
||||
```
|
||||
```
|
||||
|
||||
This will register a new logger if it does not already exist otherwise it will get an existing one. But if you have passed in `false` to the second param and logger does not already exist, `businessLogger` will be nullptr.
|
||||
|
||||
@ -763,11 +782,11 @@ Although this is a rare situation but if you wish to get list of all the logger
|
||||
### Sharing Logging Repository
|
||||
For advance logging, you can share your logging repositories to shared or static libraries, or even from library to application. This is rare case but a very good example is as follows;
|
||||
|
||||
Let's say we have an application that uses easylogging++ and has it's own configuration, now you are importing library that uses easylogging++ and wants to access logging repository of main application. You can do this using two ways;
|
||||
Let's say we have an application that uses easylogging++ and has its own configuration, now you are importing library that uses easylogging++ and wants to access logging repository of main application. You can do this using two ways;
|
||||
|
||||
* 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)`
|
||||
|
||||
|
||||
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.
|
||||
|
||||
[![top] Goto Top](#table-of-contents)
|
||||
@ -780,14 +799,14 @@ Some features require you to define macros (marked as prerequisite in each secti
|
||||
### Performance Tracking
|
||||
Prerequisite: Define macro `ELPP_FEATURE_PERFORMANCE_TRACKING`
|
||||
|
||||
One of the most notable features of Easylogging++ is its ability to track performance of your function or block of function.
|
||||
One of the most notable features of Easylogging++ is its ability to track performance of your function or block of function.
|
||||
Please note, this is not backward compatible as previously we had macros that user must had defined in order to track performance and I am sure many users had avoided in doing so. (Read v8.91 ReadMe for older way of doing it)
|
||||
The new way of tracking performance is much easier and reliable. All you need to do is use one of two macros from where you want to start tracking.
|
||||
* `TIMED_FUNC(obj-name)`
|
||||
* `TIMED_SCOPE(obj-name, block-name)`
|
||||
* `TIMED_BLOCK(obj-name, block-name)`
|
||||
|
||||
An example that just uses usleep
|
||||
An example that just uses usleep
|
||||
```c++
|
||||
void performHeavyTask(int iter) {
|
||||
TIMED_FUNC(timerObj);
|
||||
@ -801,7 +820,7 @@ void performHeavyTask(int iter) {
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
The result of above execution for iter = 10, is as following
|
||||
```
|
||||
06:22:31,368 INFO Executed [heavy-iter] in [10 ms]
|
||||
@ -819,7 +838,7 @@ The result of above execution for iter = 10, is as following
|
||||
|
||||
In the above example, we have used both the macros. In line-2 we have `TIMED_FUNC` with object pointer name timerObj and line-7 we have TIMED_SCOPE with object pointer name `timerBlkObj` and block name `heavy-iter`. Notice how block name is thrown out to the logs with every hit. (Note: `TIMED_FUNC` is `TIMED_SCOPE` with block name = function name)
|
||||
|
||||
You might wonder why do we need object name. Well easylogging++ performance tracking feature takes it further and provides ability to add, what's called checkpoints.
|
||||
You might wonder why do we need object name. Well easylogging++ performance tracking feature takes it further and provides ability to add, what's called checkpoints.
|
||||
Checkpoints have two macros:
|
||||
* `PERFORMANCE_CHECKPOINT(timed-block-obj-name)`
|
||||
* `PERFORMANCE_CHECKPOINT_WITH_ID(timed-block-obj-name, id)`
|
||||
@ -891,15 +910,15 @@ Notes:
|
||||
|
||||
4. `TIMED_BLOCK` macro resolves to a single-looped for-loop, so be careful where you define `TIMED_BLOCK`, if for-loop is allowed in the line where you use it, you should have no errors.
|
||||
|
||||
> You may be interested in [python script to parse performance logs](https://github.com/muflihun/easyloggingpp/issues/206)
|
||||
> You may be interested in [python script to parse performance logs](https://github.com/amrayn/easyloggingpp/issues/206)
|
||||
|
||||
[![top] Goto Top](#table-of-contents)
|
||||
|
||||
|
||||
#### Conditional Performance Tracking
|
||||
If you want to enable performance tracking for certain conditions only, e.g. based on a certain verbosity level, you can use the variants `TIMED_FUNC_IF` or `TIMED_SCOPE_IF`.
|
||||
|
||||
|
||||
A verbosity level example is given below
|
||||
|
||||
|
||||
```c++
|
||||
void performHeavyTask(int iter) {
|
||||
// enable performance tracking for verbosity level 4 or higher
|
||||
@ -909,7 +928,7 @@ If you want to enable performance tracking for certain conditions only, e.g. bas
|
||||
```
|
||||
|
||||
[![top] Goto Top](#table-of-contents)
|
||||
|
||||
|
||||
#### Make Use of Performance Tracking Data
|
||||
If you wish to capture performance tracking data right after it is finished, you can do so by extending `el::PerformanceTrackingCallback`.
|
||||
|
||||
@ -922,9 +941,9 @@ In order to install this handler, use `void Helpers::installPerformanceTrackingC
|
||||
### Log File Rotating
|
||||
Easylogging++ has ability to roll out (or throw away / rotate) log files if they reach certain limit. You can configure this by setting `Max_Log_File_Size`. See Configuration section above.
|
||||
|
||||
If you are having failure in log-rollout, you may have failed to add flag i.e, `el::LoggingFlags::StrictLogFileSizeCheck`.
|
||||
Rollout checking happens when Easylogging++ flushes the log file, or, if you have added the flag `el::LoggingFlags::StrictLogFileSizeCheck`, at each log output.
|
||||
|
||||
This feature has it's own section in this reference manual because you can do stuffs with the file being thrown away. This is useful, for example if you wish to back this file up etc.
|
||||
This feature has its own section in this reference manual because you can do stuffs with the file being thrown away. This is useful, for example if you wish to back this file up etc.
|
||||
This can be done by using `el::Helpers::installPreRollOutCallback(const PreRollOutCallback& handler)` where `PreRollOutCallback` is typedef of type `std::function<void(const char*, std::size_t)>`. Please note following if you are using this feature
|
||||
|
||||
There is a [sample](/samples/STL/logrotate.cpp) available that you can use as basis.
|
||||
@ -936,7 +955,7 @@ There is a [sample](/samples/STL/logrotate.cpp) available that you can use as ba
|
||||
### Crash Handling
|
||||
Prerequisite: Define macro `ELPP_FEATURE_CRASH_LOG`
|
||||
|
||||
Easylogging++ provides ability to handle unexpected crashes for GCC compilers. This is active by default and can be disabled by defining macro `ELPP_DISABLE_DEFAULT_CRASH_HANDLING`. By doing so you are telling library not to handle any crashes. Later on if you wish to handle crash yourself, you can assign crash handler of type void func(int) where int is signal caught.
|
||||
Easylogging++ provides ability to handle unexpected crashes for GCC compilers. This is active by default and can be disabled by defining macro `ELPP_DISABLE_DEFAULT_CRASH_HANDLING`. By doing so you are telling library not to handle any crashes. Later on if you wish to handle crash yourself, you can assign crash handler of type void func(int) where int is signal caught.
|
||||
|
||||
Following signals are handled;
|
||||
* SIGABRT (If `ELPP_HANDLE_SIGABRT` macro is defined)
|
||||
@ -959,7 +978,7 @@ Following are some useful macros that you can define to change the behaviour
|
||||
[![top] Goto Top](#table-of-contents)
|
||||
|
||||
#### Installing Custom Crash Handlers
|
||||
You can use your own crash handler by using `el::Helpers::setCrashHandler(const el::base::debug::CrashHandler::Handler&);`.
|
||||
You can use your own crash handler by using `el::Helpers::setCrashHandler(const el::base::debug::CrashHandler::Handler&);`.
|
||||
|
||||
> Make sure to abort application at the end of your crash handler using `el::Helpers::crashAbort(int)`. If you fail to do so, you will get into endless loop of crashes.
|
||||
|
||||
@ -1001,14 +1020,14 @@ Prerequisite: Define macro `ELPP_FEATURE_CRASH_LOG`
|
||||
Easylogging++ supports stack trace printing for GCC compilers. You can print stack trace at anytime by calling `el::base::debug::StackTrace()`, formatting will be done automatically. Note, if you are using non-GCC compiler, you will end-up getting empty output.
|
||||
|
||||
[![top] Goto Top](#table-of-contents)
|
||||
|
||||
|
||||
### Multi-threading
|
||||
Prerequisite: Define macro `ELPP_THREAD_SAFE`
|
||||
|
||||
Easylogging++ is thread-safe. By default thread-safety is disabled. You can enable it by defining `ELPP_THREAD_SAFE` otherwise you will see unexpected results. This is intentional to make library efficient for single threaded application.
|
||||
|
||||
[![top] Goto Top](#table-of-contents)
|
||||
|
||||
|
||||
### CHECK Macros
|
||||
Easylogging++ supports CHECK macros, with these macros you can quickly check whether certain condition fulfills or not. If not Easylogging++ writes FATAL log, causing application to stop (unless defined macro to prevent stopping application on fatal).
|
||||
|
||||
@ -1021,7 +1040,7 @@ Easylogging++ supports CHECK macros, with these macros you can quickly check whe
|
||||
| `CHECK_GT(a, b)` | Greater than e.g, `CHECK_GT(2, 1) << "How 2 is not greater than 1?";` |
|
||||
| `CHECK_LE(a, b)` | Less than or equal e.g, `CHECK_LE(1, 1) << "1 is not equal or less than 1";` |
|
||||
| `CHECK_GE(a, b)` | Greater than or equal e.g, `CHECK_GE(1, 1) << "1 is not equal or greater than 1";` |
|
||||
| `CHECK_NOTNULL(pointer)` | Ensures pointer is not null - if OK returns pointer e.g, `explicit MyClass(Obj* obj) : m_obj(CHECK_NOT_NULL(obj)) {}` |
|
||||
| `CHECK_NOTNULL(pointer)` | Ensures pointer is not null. This function does not return anything |
|
||||
| `CHECK_STREQ(str1, str2)` | C-string equality (case-sensitive) e.g, `CHECK_STREQ(argv[1], "0") << "First arg cannot be 0";` |
|
||||
| `CHECK_STRNE(str1, str2)` | C-string inequality (case-sensitive) e.g, `CHECK_STRNE(username1, username2) << "Usernames cannot be same";` |
|
||||
| `CHECK_STRCASEEQ(str1, str2)` | C-string inequality (*case-insensitive*) e.g, `CHECK_CASESTREQ(argv[1], "Z") << "First arg cannot be 'z' or 'Z'";` |
|
||||
@ -1031,7 +1050,7 @@ Easylogging++ supports CHECK macros, with these macros you can quickly check whe
|
||||
> Same versions of macros are available for `DEBUG` only mode, these macros start with `D` (for debug) followed by the same name. e.g, `DCHECK` to check only in debug mode (i.e, when `_DEBUG` is defined or `NDEBUG` is undefined)
|
||||
|
||||
[![top] Goto Top](#table-of-contents)
|
||||
|
||||
|
||||
### Logging perror()
|
||||
Easylogging++ supports `perror()` styled logging using `PLOG(LEVEL)`, `PLOG_IF(Condition, LEVEL)`, and `PCHECK()` using `default` logger; and for custom logger use `CPLOG(LEVEL, LoggerId)`, `CPLOG_IF(Condition, LEVEL, LoggerId)`. This will append `: log-error [errno]` in the end of log line.
|
||||
|
||||
@ -1067,7 +1086,7 @@ Syslog support for Easylogging++ only supports following levels; each level is c
|
||||
Following levels are not supported and correspond to `LOG_NOTICE`: TRACE, whereas VERBOSE level is completely not supported
|
||||
|
||||
[![top] Goto Top](#table-of-contents)
|
||||
|
||||
|
||||
### STL Logging
|
||||
Prerequisite: Define macro `ELPP_STL_LOGGING`
|
||||
|
||||
@ -1098,7 +1117,7 @@ Some C++11 specific templates are supported by further explicit macro definition
|
||||
Standard manipulators are also supported, in addition std::stringstream is also supported.
|
||||
|
||||
[![top] Goto Top](#table-of-contents)
|
||||
|
||||
|
||||
### Qt Logging
|
||||
Prerequisite: Define macro `ELPP_QT_LOGGING`
|
||||
|
||||
@ -1170,6 +1189,10 @@ You may also have a look at wxWidgets sample
|
||||
[![top] Goto Top](#table-of-contents)
|
||||
|
||||
### Extending Library
|
||||
You can extend this library using various callback handlers and inheritable classes.
|
||||
|
||||
A perfect example of using these features is the logging server built with this library. It's called [Residue](https://github.com/amrayn/residue/) that is feature rich. In fact, you may be interested in using that instead of this library for your medium to large sized projects.
|
||||
|
||||
#### Logging Your Own Class
|
||||
|
||||
You can log your own classes by extending `el::Loggable` class and implementing pure-virtual function `void log(std::ostream& os) const`. Following example shows a good way to extend a class.
|
||||
@ -1259,57 +1282,131 @@ This may not be practically best implementation but you get the point.
|
||||
### Manually Flushing and Rolling Log Files
|
||||
You can manually flush log files using `el::Logger::flush()` (to flush single logger with all referencing log files) or `el::Loggers::flushAll()` (to flush all log files for all levels).
|
||||
|
||||
If you have not set flag `LoggingFlag::StrictLogFileSizeCheck` for some reason, you can manually check for log files that need rolling; by using `el::Helpers::validateFileRolling(el::Logger*, const el::Level&)`.
|
||||
If you have not set flag `LoggingFlag::StrictLogFileSizeCheck` for some reason, you can manually check for log files that need rolling; by using `el::Helpers::validateFileRolling(el::Logger*, const el::Level&)`.
|
||||
|
||||
[![top] Goto Top](#table-of-contents)
|
||||
|
||||
### Log Dispatch Callback
|
||||
If you wish to capture log message right after it is dispatched, you can do so by having a class that extends `el::LogDispatchCallback` and implement the pure-virtual functions, then install it at anytime using `el::Helpers::installLogDispatchCallback<T>(const std::string&)`. If you wish to uninstall a pre-installed handler with same ID, you can do so by using `el::Helpers::uninstallLogDispatchCallback<T>(const std::string&)`
|
||||
|
||||
You can use this feature to send it to custom destinations e.g, log stash or TCP client etc.
|
||||
|
||||
You can also look at [send-to-network](/samples/send-to-network) sample for practical usage of this.
|
||||
|
||||
```c++
|
||||
// samples/send-to-network/network-logger.cpp
|
||||
|
||||
#include "easylogging++.h"
|
||||
|
||||
#include <boost/asio.hpp>
|
||||
|
||||
INITIALIZE_EASYLOGGINGPP
|
||||
|
||||
|
||||
class Client
|
||||
{
|
||||
boost::asio::io_service* io_service;
|
||||
boost::asio::ip::tcp::socket socket;
|
||||
|
||||
public:
|
||||
Client(boost::asio::io_service* svc, const std::string& host, const std::string& port)
|
||||
: io_service(svc), socket(*io_service)
|
||||
{
|
||||
boost::asio::ip::tcp::resolver resolver(*io_service);
|
||||
boost::asio::ip::tcp::resolver::iterator endpoint = resolver.resolve(boost::asio::ip::tcp::resolver::query(host, port));
|
||||
boost::asio::connect(this->socket, endpoint);
|
||||
};
|
||||
|
||||
void send(std::string const& message) {
|
||||
socket.send(boost::asio::buffer(message));
|
||||
}
|
||||
};
|
||||
|
||||
class NetworkDispatcher : public el::LogDispatchCallback
|
||||
{
|
||||
public:
|
||||
void updateServer(const std::string& host, int port) {
|
||||
m_client = std::unique_ptr<Client>(new Client(&m_svc, host, std::to_string(port)));
|
||||
}
|
||||
protected:
|
||||
void handle(const el::LogDispatchData* data) noexcept override {
|
||||
m_data = data;
|
||||
// Dispatch using default log builder of logger
|
||||
dispatch(m_data->logMessage()->logger()->logBuilder()->build(m_data->logMessage(),
|
||||
m_data->dispatchAction() == el::base::DispatchAction::NormalLog));
|
||||
}
|
||||
private:
|
||||
const el::LogDispatchData* m_data;
|
||||
boost::asio::io_service m_svc;
|
||||
std::unique_ptr<Client> m_client;
|
||||
|
||||
void dispatch(el::base::type::string_t&& logLine) noexcept
|
||||
{
|
||||
m_client->send(logLine);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
int main() {
|
||||
el::Helpers::installLogDispatchCallback<NetworkDispatcher>("NetworkDispatcher");
|
||||
// you can uninstall default one by
|
||||
// el::Helpers::uninstallLogDispatchCallback<el::base::DefaultLogDispatchCallback>("DefaultLogDispatchCallback");
|
||||
// Set server params
|
||||
NetworkDispatcher* dispatcher = el::Helpers::logDispatchCallback<NetworkDispatcher>("NetworkDispatcher");
|
||||
dispatcher->setEnabled(true);
|
||||
dispatcher->updateServer("127.0.0.1", 9090);
|
||||
|
||||
// Start logging and normal program...
|
||||
LOG(INFO) << "First network log";
|
||||
|
||||
// You can even use a different logger, say "network" and send using a different log pattern
|
||||
}
|
||||
```
|
||||
|
||||
> DO NOT LOG ANYTHING IN THIS HANDLER OR YOU WILL END UP IN INFINITE-LOOP
|
||||
|
||||
[![top] Goto Top](#table-of-contents)
|
||||
|
||||
### Logger Registration Callback
|
||||
If you wish to capture event of logger registration (and potentially want to reconfigure this logger without changing default configuration) you can use `el::LoggerRegistrationCallback`. The syntax is similar to [other callbacks](#log-dispatch-callback). You can use [this sample](https://github.com/muflihun/easyloggingpp/blob/master/samples/STL/new-logger-registration-callback.cpp) as basis.
|
||||
If you wish to capture event of logger registration (and potentially want to reconfigure this logger without changing default configuration) you can use `el::LoggerRegistrationCallback`. The syntax is similar to [other callbacks](#log-dispatch-callback). You can use [this sample](https://github.com/amrayn/easyloggingpp/blob/master/samples/STL/new-logger-registration-callback.cpp) as basis.
|
||||
|
||||
> DO NOT LOG ANYTHING IN THIS HANDLER
|
||||
|
||||
[![top] Goto Top](#table-of-contents)
|
||||
|
||||
|
||||
### Asynchronous Logging
|
||||
Prerequisite: Define macro `ELPP_EXPERIMENTAL_ASYNC`
|
||||
|
||||
Asynchronous logging is in experimental stages and they are not widely promoted. You may enable and test this feature by defining macro `ELPP_EXPERIMENTAL_ASYNC` and if you find some issue with the feature please report in [this issue](https://github.com/muflihun/easyloggingpp/issues/202). Reporting issues always help for constant improvements.
|
||||
Asynchronous logging is in experimental stages and they are not widely promoted. You may enable and test this feature by defining macro `ELPP_EXPERIMENTAL_ASYNC` and if you find some issue with the feature please report in [this issue](https://github.com/amrayn/easyloggingpp/issues/202). Reporting issues always help for constant improvements.
|
||||
|
||||
Please note:
|
||||
* Asynchronous will only work with few compilers (it purely uses `std::thread`)
|
||||
* Compiler should support `std::this_thread::sleep_for`. This restriction may (or may not) be removed in future (stable) version of asynchronous logging.
|
||||
* You should not rely on asynchronous logging in production, this is because feature is in experiemental stages.
|
||||
* You should not rely on asynchronous logging in production, this is because feature is in experimental stages.
|
||||
|
||||
[![top] Goto Top](#table-of-contents)
|
||||
|
||||
|
||||
### Helper Classes
|
||||
There are static helper classes available to make it easy to do stuffs;
|
||||
|
||||
* `el::Helpers`
|
||||
* `el::Loggers`
|
||||
|
||||
You can do various cool stuffs using functions in these classes, see [this issue](https://github.com/muflihun/easyloggingpp/issues/210) for instance.
|
||||
You can do various cool stuffs using functions in these classes, see [this issue](https://github.com/amrayn/easyloggingpp/issues/210) for instance.
|
||||
|
||||
[![top] Goto Top](#table-of-contents)
|
||||
|
||||
|
||||
# Contribution
|
||||
### Submitting Patches
|
||||
You can submit patches to `develop` branch and we will try and merge them. Since it's based on single header, it can be sometimes difficult to merge without having merge conflicts.
|
||||
|
||||
[![top] Goto Top](#table-of-contents)
|
||||
|
||||
|
||||
### Reporting a Bug
|
||||
If you have found a bug and wish to report it, feel free to do so at [github issue tracker](https://github.com/muflihun/easyloggingpp/issues?state=open). I will try to look at it as soon as possible. Some information should be provided to make it easy to reproduce;
|
||||
If you have found a bug and wish to report it, feel free to do so at [github issue tracker](https://github.com/amrayn/easyloggingpp/issues?state=open). I will try to look at it as soon as possible. Some information should be provided to make it easy to reproduce;
|
||||
* Platform (OS, Compiler)
|
||||
* Log file location
|
||||
* Macros defined (on compilation) OR simple compilation
|
||||
* Macros defined (on compilation) OR simple compilation
|
||||
* Please assign issue label.
|
||||
|
||||
Try to provide as much information as possible. Any bug with no clear information will be ignored and closed.
|
||||
@ -1318,11 +1415,11 @@ Try to provide as much information as possible. Any bug with no clear informatio
|
||||
|
||||
# Compatibility
|
||||
|
||||
Easylogging++ requires a decent C++0x complient compiler. Some compilers known to work with v9.0+ are shown in table below, for older versions please refer to readme on corresponding release at github
|
||||
Easylogging++ requires a decent C++0x compliant compiler. Some compilers known to work with v9.0+ are shown in table below, for older versions please refer to readme on corresponding release at github
|
||||
|
||||
| ***** | Compiler/Platform | Notes |
|
||||
|---------|---------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
|![gcc] | GCC 4.7+ | Stack trace logging. Very close to support GCC 4.6 if it had supported strong enum types casting to underlying type. It causes internal compiler error. |
|
||||
|![gcc] | GCC 4.6.4+ | Stack trace logging. Very close to support GCC 4.6.0 if it had supported strong enum types casting to underlying type. It causes internal compiler error. |
|
||||
|![llvm] | Clang++ 3.1+ | Stack trace logging only with gcc compliant. |
|
||||
|![intel] | Intel C++ 13.0+ | Workarounds to support: Use if instead of switch on strong enum type. No `final` keyword etc. Stack trace logging only with gcc compliant |
|
||||
|![vcpp] | Visual C++ 11.0+ | Tested with VS2012, VS2013; Use of argument templates instead of variadic templates. CRT warnings control. No stack trace logging. |
|
||||
@ -1348,6 +1445,7 @@ Operating systems that have been tested are shown in table below. Easylogging++
|
||||
|![android] | Android | Tested with C4droid (g++) on Galaxy Tab 2 |
|
||||
|![raspberrypi] | RaspberryPi 7.6 | Tested with 7.6.2-1.1 (gcc version 4.9.1 (Raspbian 4.9.1-1)) by contributor |
|
||||
|![solaris] | Solaris i86 | Tested by contributor |
|
||||
|![aix] | IBM AIX | Support added by contributor |
|
||||
|
||||
Easylogging++ has also been tested with following C++ libraries;
|
||||
|
||||
@ -1359,15 +1457,33 @@ Easylogging++ has also been tested with following C++ libraries;
|
||||
|![gtkmm] | gtkmm | Tested with gtkmm 2.4 |
|
||||
|
||||
[![top] Goto Top](#table-of-contents)
|
||||
|
||||
|
||||
## Build Matrix
|
||||
|
||||
| Branch | Platform | Build Status |
|
||||
| -------- |:------------:|:------------:|
|
||||
| `develop` | GNU/Linux 4.4 / Ubuntu 4.8.4 64-bit / `clang++` | [](https://travis-ci.org/amrayn/easyloggingpp) |
|
||||
| `develop` | GNU/Linux 4.4 / Ubuntu 4.8.4 64-bit / `g++-4.9` | [](https://travis-ci.org/amrayn/easyloggingpp) |
|
||||
| `develop` | GNU/Linux 4.4 / Ubuntu 4.8.4 64-bit / `g++-5` | [](https://travis-ci.org/amrayn/easyloggingpp) |
|
||||
| `develop` | GNU/Linux 4.4 / Ubuntu 4.8.4 64-bit / `g++-6` | [](https://travis-ci.org/amrayn/easyloggingpp) |
|
||||
| `develop` | GNU/Linux 4.4 / Ubuntu 4.8.4 64-bit / `g++-7` | [](https://travis-ci.org/amrayn/easyloggingpp) |
|
||||
| `master` | GNU/Linux 4.4 / Ubuntu 4.8.4 64-bit / `clang++` | [](https://travis-ci.org/amrayn/easyloggingpp) |
|
||||
| `master` | GNU/Linux 4.4 / Ubuntu 4.8.4 64-bit / `g++-4.9` | [](https://travis-ci.org/amrayn/easyloggingpp) |
|
||||
| `master` | GNU/Linux 4.4 / Ubuntu 4.8.4 64-bit / `g++-5` | [](https://travis-ci.org/amrayn/easyloggingpp) |
|
||||
| `master` | GNU/Linux 4.4 / Ubuntu 4.8.4 64-bit / `g++-6` | [](https://travis-ci.org/amrayn/easyloggingpp) |
|
||||
| `master` | GNU/Linux 4.4 / Ubuntu 4.8.4 64-bit / `g++-7` | [](https://travis-ci.org/amrayn/easyloggingpp) |
|
||||
|
||||
[![top] Goto Top](#table-of-contents)
|
||||
|
||||
# Licence
|
||||
```
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2017 muflihun.com
|
||||
Copyright (c) 2012-2018 Amrayn Web Services
|
||||
Copyright (c) 2012-2018 @abumusamq
|
||||
|
||||
https://github.com/muflihun/easyloggingpp
|
||||
https://labs.muflihun.com
|
||||
https://github.com/amrayn/
|
||||
https://amrayn.com
|
||||
https://muflihun.com
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
@ -1389,7 +1505,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
```
|
||||
|
||||
[![top] Goto Top](#table-of-contents)
|
||||
|
||||
|
||||
# Disclaimer
|
||||
Icons used in this manual (in compatibility section) are solely for information readability purposes. I do not own these icons. If anyone has issues with usage of these icon, please feel free to contact me via company's email and I will look for an alternative. Company's email address is required so that I can verify the ownership, any other email address for this purpose will be ignored.
|
||||
|
||||
@ -1397,39 +1513,39 @@ Icons used in this manual (in compatibility section) are solely for information
|
||||
|
||||
|
||||
[![top] Goto Top](#table-of-contents)
|
||||
|
||||
[banner]: https://raw.githubusercontent.com/muflihun/easyloggingpp.muflihun.com/master/images/banner.png?v=4
|
||||
[ubuntu]: https://raw.githubusercontent.com/muflihun/easyloggingpp.muflihun.com/master/images/icons/ubuntu.png?v=2
|
||||
[mint]: https://raw.githubusercontent.com/muflihun/easyloggingpp.muflihun.com/master/images/icons/linux-mint.png?v=2
|
||||
[freebsd]: https://raw.githubusercontent.com/muflihun/easyloggingpp.muflihun.com/master/images/icons/free-bsd.png?v=2
|
||||
[sl]: https://raw.githubusercontent.com/muflihun/easyloggingpp.muflihun.com/master/images/icons/scientific-linux.png?v=2
|
||||
[fedora]: https://raw.githubusercontent.com/muflihun/easyloggingpp.muflihun.com/master/images/icons/fedora.png?v=3
|
||||
[mac]: https://raw.githubusercontent.com/muflihun/easyloggingpp.muflihun.com/master/images/icons/mac-osx.png?v=2
|
||||
[winxp]: https://raw.githubusercontent.com/muflihun/easyloggingpp.muflihun.com/master/images/icons/windowsxp.png?v=2
|
||||
[win7]: https://raw.githubusercontent.com/muflihun/easyloggingpp.muflihun.com/master/images/icons/windows7.png?v=2
|
||||
[win8]: https://raw.githubusercontent.com/muflihun/easyloggingpp.muflihun.com/master/images/icons/windows8.png?v=2
|
||||
[win10]: https://raw.githubusercontent.com/muflihun/easyloggingpp.muflihun.com/master/images/icons/windows10.png?v=2
|
||||
[qt]: https://raw.githubusercontent.com/muflihun/easyloggingpp.muflihun.com/master/images/icons/qt.png?v=3
|
||||
[boost]: https://raw.githubusercontent.com/muflihun/easyloggingpp.muflihun.com/master/images/icons/boost.png?v=3
|
||||
[wxwidgets]: https://raw.githubusercontent.com/muflihun/easyloggingpp.muflihun.com/master/images/icons/wxwidgets.png?v=3
|
||||
[devcpp]: https://raw.githubusercontent.com/muflihun/easyloggingpp.muflihun.com/master/images/icons/devcpp.png?v=3
|
||||
[gtkmm]: https://raw.githubusercontent.com/muflihun/easyloggingpp.muflihun.com/master/images/icons/gtkmm.png?v=3
|
||||
[tdm]: https://raw.githubusercontent.com/muflihun/easyloggingpp.muflihun.com/master/images/icons/tdm.png?v=3
|
||||
[raspberrypi]: https://raw.githubusercontent.com/muflihun/easyloggingpp.muflihun.com/master/images/icons/raspberry-pi.png?v=3
|
||||
[solaris]: https://raw.githubusercontent.com/muflihun/easyloggingpp.muflihun.com/master/images/icons/solaris.png?v=3
|
||||
|
||||
[banner]: https://amrayn.github.io/easyloggingpp/images/banner.png?v=4
|
||||
[ubuntu]: https://amrayn.github.io/easyloggingpp/images/icons/ubuntu.png?v=2
|
||||
[mint]: https://amrayn.github.io/easyloggingpp/images/icons/linux-mint.png?v=2
|
||||
[freebsd]: https://amrayn.github.io/easyloggingpp/images/icons/free-bsd.png?v=2
|
||||
[sl]: https://amrayn.github.io/easyloggingpp/images/icons/scientific-linux.png?v=2
|
||||
[fedora]: https://amrayn.github.io/easyloggingpp/images/icons/fedora.png?v=3
|
||||
[mac]: https://amrayn.github.io/easyloggingpp/images/icons/mac-osx.png?v=2
|
||||
[winxp]: https://amrayn.github.io/easyloggingpp/images/icons/windowsxp.png?v=2
|
||||
[win7]: https://amrayn.github.io/easyloggingpp/images/icons/windows7.png?v=2
|
||||
[win8]: https://amrayn.github.io/easyloggingpp/images/icons/windows8.png?v=2
|
||||
[win10]: https://amrayn.github.io/easyloggingpp/images/icons/windows10.png?v=2
|
||||
[qt]: https://amrayn.github.io/easyloggingpp/images/icons/qt.png?v=3
|
||||
[boost]: https://amrayn.github.io/easyloggingpp/images/icons/boost.png?v=3
|
||||
[wxwidgets]: https://amrayn.github.io/easyloggingpp/images/icons/wxwidgets.png?v=3
|
||||
[devcpp]: https://amrayn.github.io/easyloggingpp/images/icons/devcpp.png?v=3
|
||||
[gtkmm]: https://amrayn.github.io/easyloggingpp/images/icons/gtkmm.png?v=3
|
||||
[tdm]: https://amrayn.github.io/easyloggingpp/images/icons/tdm.png?v=3
|
||||
[raspberrypi]: https://amrayn.github.io/easyloggingpp/images/icons/raspberry-pi.png?v=3
|
||||
[solaris]: https://amrayn.github.io/easyloggingpp/images/icons/solaris.png?v=3
|
||||
[aix]: https://amrayn.github.io/easyloggingpp/images/icons/aix.png?v=4
|
||||
|
||||
|
||||
[gcc]: https://raw.githubusercontent.com/muflihun/easyloggingpp.muflihun.com/master/images/icons/gcc.png?v=4
|
||||
[mingw]: https://raw.githubusercontent.com/muflihun/easyloggingpp.muflihun.com/master/images/icons/mingw.png?v=2
|
||||
[cygwin]: https://raw.githubusercontent.com/muflihun/easyloggingpp.muflihun.com/master/images/icons/cygwin.png?v=2
|
||||
[vcpp]: https://raw.githubusercontent.com/muflihun/easyloggingpp.muflihun.com/master/images/icons/vcpp.png?v=2
|
||||
[llvm]: https://raw.githubusercontent.com/muflihun/easyloggingpp.muflihun.com/master/images/icons/llvm.png?v=2
|
||||
[intel]: https://raw.githubusercontent.com/muflihun/easyloggingpp.muflihun.com/master/images/icons/intel.png?v=2
|
||||
[android]: https://raw.githubusercontent.com/muflihun/easyloggingpp.muflihun.com/master/images/icons/android.png?v=2
|
||||
[manual]: https://raw.githubusercontent.com/muflihun/easyloggingpp.muflihun.com/master/images/help.png?v=3
|
||||
[download]: https://raw.githubusercontent.com/muflihun/easyloggingpp.muflihun.com/master/images/download.png?v=2
|
||||
[samples]: https://raw.githubusercontent.com/muflihun/easyloggingpp.muflihun.com/master/images/sample.png?v=2
|
||||
[notes]: https://raw.githubusercontent.com/muflihun/easyloggingpp.muflihun.com/master/images/notes.png?v=4
|
||||
[top]: https://raw.githubusercontent.com/muflihun/easyloggingpp.muflihun.com/master/images/up.png?v=4
|
||||
[www]: https://raw.githubusercontent.com/muflihun/easyloggingpp.muflihun.com/master/images/logo-www.png?v=6
|
||||
|
||||
[gcc]: https://amrayn.github.io/easyloggingpp/images/icons/gcc.png?v=4
|
||||
[mingw]: https://amrayn.github.io/easyloggingpp/images/icons/mingw.png?v=2
|
||||
[cygwin]: https://amrayn.github.io/easyloggingpp/images/icons/cygwin.png?v=2
|
||||
[vcpp]: https://amrayn.github.io/easyloggingpp/images/icons/vcpp.png?v=2
|
||||
[llvm]: https://amrayn.github.io/easyloggingpp/images/icons/llvm.png?v=2
|
||||
[intel]: https://amrayn.github.io/easyloggingpp/images/icons/intel.png?v=2
|
||||
[android]: https://amrayn.github.io/easyloggingpp/images/icons/android.png?v=2
|
||||
[manual]: https://amrayn.github.io/easyloggingpp/images/help.png?v=3
|
||||
[download]: https://amrayn.github.io/easyloggingpp/images/download.png?v=2
|
||||
[samples]: https://amrayn.github.io/easyloggingpp/images/sample.png?v=2
|
||||
[notes]: https://amrayn.github.io/easyloggingpp/images/notes.png?v=4
|
||||
[top]: https://amrayn.github.io/easyloggingpp/images/up.png?v=4
|
||||
[www]: https://amrayn.github.io/easyloggingpp/images/logo-www.png?v=6
|
||||
|
@ -6,9 +6,10 @@
|
||||
# If ${EASYLOGGINGPP_USE_STATIC_LIBS} is ON then static libs are searched.
|
||||
# In these cases ${EASYLOGGINGPP_LIBRARY} is also defined
|
||||
#
|
||||
# (c) 2017 Muflihun Labs
|
||||
# (c) 2017-2018 Amrayn Web Services
|
||||
#
|
||||
# https://github.com/muflihun/easyloggingpp
|
||||
# https://github.com/amrayn/easyloggingpp
|
||||
# https://amrayn.com
|
||||
# https://muflihun.com
|
||||
#
|
||||
|
||||
|
6
cmake/easyloggingpp.pc.cmakein
Normal file
6
cmake/easyloggingpp.pc.cmakein
Normal file
@ -0,0 +1,6 @@
|
||||
Name: easyloggingpp
|
||||
Description: Feature-rich single header C++ logging library
|
||||
Version: @ELPP_VERSION_STRING@
|
||||
prefix=@CMAKE_INSTALL_PREFIX@
|
||||
includedir=@ELPP_INCLUDE_INSTALL_DIR@
|
||||
Cflags: -I${includedir}
|
@ -18,7 +18,7 @@ Easylogging++ v9.09 RELEASE NOTES
|
||||
= REFACTORING =
|
||||
==========================
|
||||
|
||||
- Seperated writer from dispatcher + log class
|
||||
- Separated writer from dispatcher + log class
|
||||
|
||||
==========================
|
||||
= NOTES =
|
||||
|
@ -12,7 +12,7 @@ Easylogging++ v9.17 RELEASE NOTES
|
||||
= IMPROVEMENTS =
|
||||
=============================
|
||||
|
||||
- Assertion failure and does not process when configuratoin file does not exist
|
||||
- Assertion failure and does not process when configuration file does not exist
|
||||
|
||||
==========================
|
||||
= NOTES =
|
||||
|
@ -6,14 +6,14 @@ Easylogging++ v9.18 RELEASE NOTES
|
||||
= FIXES =
|
||||
==========================
|
||||
|
||||
- Completely dithced away QA logging even macros unusable
|
||||
- Completely ditched away QA logging even macros unusable
|
||||
- Fixed some of verbose logging macro expansions
|
||||
|
||||
==========================
|
||||
= NEW FEATURES =
|
||||
==========================
|
||||
|
||||
- Only allow aplha-numeric (+ some symbols) for logger names (issue #105)
|
||||
- Only allow alpha-numeric (+ some symbols) for logger names (issue #105)
|
||||
- Case insensitive app args (issue #106)
|
||||
- Helper to reconfigure specific level for all loggers (issue #107)
|
||||
- DCHECK macros for debug mode checks (issue #108)
|
||||
|
@ -16,7 +16,7 @@ Easylogging++ v9.21 RELEASE NOTES
|
||||
- Configuring same logger twice loses some information (issue #116)
|
||||
|
||||
==========================
|
||||
= NEW FEATRUES =
|
||||
= NEW FEATURES =
|
||||
==========================
|
||||
|
||||
- Added base configurations pointer to `parseFromText` same as `parseFromFile`
|
||||
|
@ -14,7 +14,7 @@ Easylogging++ v9.25 RELEASE NOTES
|
||||
==========================
|
||||
|
||||
- Default log file using command line args (issue #122)
|
||||
- Introduced `LoggingFlag::ImmediateFlush` for performance imporvement (issue #127)
|
||||
- Introduced `LoggingFlag::ImmediateFlush` for performance improvement (issue #127)
|
||||
- Introduced `ConfigurationType::LogFlushThreshold` to manually specify log flush threshold (issue #126)
|
||||
- Introduced `Logger::flush` family and `Loggers::flushAll` family of function to manually flush log files (issue #128)
|
||||
- Introduced command line arg to enable/disable logging flag using `--logging-flags` param (issue #129)
|
||||
|
@ -21,7 +21,7 @@ API changes: No
|
||||
= BUG FIXES =
|
||||
==========================
|
||||
|
||||
- Double free corrpution when sharing storage
|
||||
- Double free corruption when sharing storage
|
||||
- Unused variable warning on Windows regarding "nextTok_" (issue #161)
|
||||
|
||||
==========================
|
||||
|
@ -10,6 +10,6 @@ Breaking Change: No
|
||||
==========================
|
||||
|
||||
- Updated github repo
|
||||
- See https://github.com/muflihun/easyloggingpp/blob/v9.92/README.md for manual for this release
|
||||
- See https://github.com/muflihun/easyloggingpp/tree/master/doc for other release notes
|
||||
- Closed issues: https://github.com/muflihun/easyloggingpp/issues?page=1&state=closed
|
||||
- See https://github.com/amrayn/easyloggingpp/blob/v9.92/README.md for manual for this release
|
||||
- See https://github.com/amrayn/easyloggingpp/tree/master/doc for other release notes
|
||||
- Closed issues: https://github.com/amrayn/easyloggingpp/issues?page=1&state=closed
|
||||
|
@ -23,6 +23,6 @@ Breaking Change: No
|
||||
= NOTES =
|
||||
==========================
|
||||
|
||||
- See https://github.com/muflihun/easyloggingpp/blob/9.93/README.md for manual for this release
|
||||
- See https://github.com/muflihun/easyloggingpp/tree/master/doc for other release notes
|
||||
- Closed issues: https://github.com/muflihun/easyloggingpp/issues?page=1&state=closed
|
||||
- See https://github.com/amrayn/easyloggingpp/blob/9.93/README.md for manual for this release
|
||||
- See https://github.com/amrayn/easyloggingpp/tree/master/doc for other release notes
|
||||
- Closed issues: https://github.com/amrayn/easyloggingpp/issues?page=1&state=closed
|
||||
|
@ -24,6 +24,6 @@ Breaking Change: No
|
||||
= NOTES =
|
||||
==========================
|
||||
|
||||
- See https://github.com/muflihun/easyloggingpp/blob/9.93/README.md for manual for this release
|
||||
- See https://github.com/muflihun/easyloggingpp/tree/master/doc for other release notes
|
||||
- Closed issues: https://github.com/muflihun/easyloggingpp/issues?page=1&state=closed
|
||||
- See https://github.com/amrayn/easyloggingpp/blob/9.93/README.md for manual for this release
|
||||
- See https://github.com/amrayn/easyloggingpp/tree/master/doc for other release notes
|
||||
- Closed issues: https://github.com/amrayn/easyloggingpp/issues?page=1&state=closed
|
||||
|
17
easyloggingpp.pri
Normal file
17
easyloggingpp.pri
Normal file
@ -0,0 +1,17 @@
|
||||
QT += core
|
||||
|
||||
CONFIG += c++11
|
||||
|
||||
INCLUDEPATH += $$PWD/src
|
||||
|
||||
DEFINES += ELPP_QT_LOGGING \
|
||||
ELPP_STL_LOGGING \
|
||||
ELPP_STRICT_SIZE_CHECK ELPP_UNICODE \
|
||||
ELPP_MULTI_LOGGER_SUPPORT \
|
||||
ELPP_THREAD_SAFE \
|
||||
ELPP_UNICODE \
|
||||
ELPP_NO_DEFAULT_LOG_FILE
|
||||
|
||||
SOURCES += $$PWD/src/easylogging++.cc
|
||||
|
||||
HEADERS += $$PWD/src/easylogging++.h
|
@ -89,7 +89,7 @@ void ListWithSearch::performSearch(void)
|
||||
} else {
|
||||
LOG(INFO) << "Performing search... [" << txtSearchCriteria->text().toStdString() << "]";
|
||||
for (int i = items.count() - 1; i >= 0; --i) {
|
||||
if (items.at(i)->text().startsWith(txtSearchCriteria->text(), searchBehaviour_ == kCaseSensative ?
|
||||
if (items.at(i)->text().startsWith(txtSearchCriteria->text(), searchBehaviour_ == kCaseSensitive ?
|
||||
Qt::CaseSensitive : Qt::CaseInsensitive)) {
|
||||
list->insertItem(i, items.at(i));
|
||||
}
|
||||
|
@ -19,9 +19,9 @@ class ListWithSearch : public QWidget
|
||||
|
||||
public:
|
||||
static int kSearchBarHeight;
|
||||
enum kBehaviour { kCaseInsensative, kCaseSensative };
|
||||
enum kBehaviour { kCaseInsensitive, kCaseSensitive };
|
||||
|
||||
explicit ListWithSearch(int searchBehaviour_ = kCaseSensative, QWidget *parent = 0);
|
||||
explicit ListWithSearch(int searchBehaviour_ = kCaseSensitive, QWidget *parent = 0);
|
||||
virtual ~ListWithSearch();
|
||||
void add(const QString& item);
|
||||
void resizeEvent(QResizeEvent *);
|
||||
|
@ -34,7 +34,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
{
|
||||
ui->setupUi(this);
|
||||
this->setWindowTitle("Fast Dictionary Sample - Easylogging++");
|
||||
list = new ListWithSearch(ListWithSearch::kCaseInsensative, this);
|
||||
list = new ListWithSearch(ListWithSearch::kCaseInsensitive, this);
|
||||
this->setGeometry(0, 0, 800, 600);
|
||||
initializeDictionary("words.txt");
|
||||
list->setFocus();
|
||||
|
@ -56,7 +56,7 @@
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string><html><head/><body><p><a href="https://github.com/muflihun/easyloggingpp"><span style=" text-decoration: underline; color:#0000ff;">Github</span></a></p></body></html></string>
|
||||
<string><html><head/><body><p><a href="https://github.com/amrayn/easyloggingpp"><span style=" text-decoration: underline; color:#0000ff;">Github</span></a></p></body></html></string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_3">
|
||||
|
@ -220,6 +220,6 @@ void PartProcessor::run(void) {
|
||||
status = merge();
|
||||
}
|
||||
if (status == -1) {
|
||||
LOG(ERROR) << "Error occured while " << (processType == kSplit ? "splitting" : "merging");
|
||||
LOG(ERROR) << "Error occurred while " << (processType == kSplit ? "splitting" : "merging");
|
||||
}
|
||||
}
|
||||
|
1
samples/STL/.gitignore
vendored
1
samples/STL/.gitignore
vendored
@ -1,2 +1,3 @@
|
||||
bin/*
|
||||
logs/*
|
||||
myeasylog.log
|
||||
|
@ -10,6 +10,7 @@ macro="$macro -DELPP_LOG_UNORDERED_MAP"
|
||||
macro="$macro -DELPP_FEATURE_CRASH_LOG"
|
||||
macro="$macro -DELPP_LOGGING_FLAGS_FROM_ARG"
|
||||
macro="$macro -DELPP_FEATURE_ALL"
|
||||
macro="$macro -DELPP_NO_GLOBAL_LOCK"
|
||||
# macro="$macro -DELPP_DEFAULT_LOG_FILE=\"/a/path/that/does/not/exist/f.log\""
|
||||
|
||||
if [ "$2" = "" ];then
|
||||
@ -18,7 +19,7 @@ else
|
||||
COMPILER=$2
|
||||
fi
|
||||
|
||||
CXX_STD='-std=c++0x -pthread'
|
||||
CXX_STD='-std=c++11'
|
||||
|
||||
if [ "$FILE" = "" ]; then
|
||||
echo "Please provide filename to compile"
|
||||
@ -27,7 +28,7 @@ fi
|
||||
|
||||
echo "Compiling... [$FILE]"
|
||||
|
||||
COMPILE_LINE="$COMPILER $FILE easylogging++.cc -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 -pthread -Wall -Wextra -pedantic -pedantic-errors -Werror -Wfatal-errors -Wundef -Wunused"
|
||||
|
||||
echo " $COMPILE_LINE"
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// This file is part of Easylogging++ samples
|
||||
//
|
||||
// Demonstration on how crashes are handled. You can set second argument of this progam to `y`
|
||||
// Demonstration on how crashes are handled. You can set second argument of this program to `y`
|
||||
// and application will not abort before crash is handled
|
||||
//
|
||||
// Revision 1.1
|
||||
|
@ -16,9 +16,12 @@ int main(int argc, char** argv) {
|
||||
|
||||
el::Logger* defaultLogger = el::Loggers::getLogger("default");
|
||||
|
||||
LOG(INFO) << "Blah";
|
||||
|
||||
std::vector<int> i;
|
||||
i.push_back(1);
|
||||
i.push_back(2);
|
||||
defaultLogger->info("simple %v", "msg");
|
||||
defaultLogger->warn("My first ultimate log message %v %v %v", 123, 222, i);
|
||||
|
||||
// Escaping
|
||||
@ -27,5 +30,6 @@ int main(int argc, char** argv) {
|
||||
defaultLogger->verbose(1, "test verbose");
|
||||
defaultLogger->verbose(1, "test verbose with args %v", 2);
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
39
samples/STL/multi-loggers-to-same-file.cpp
Normal file
39
samples/STL/multi-loggers-to-same-file.cpp
Normal file
@ -0,0 +1,39 @@
|
||||
//
|
||||
// This file is part of Easylogging++ samples
|
||||
//
|
||||
// Revision 1.0
|
||||
//
|
||||
|
||||
#include <thread>
|
||||
#include "easylogging++.h"
|
||||
|
||||
INITIALIZE_EASYLOGGINGPP
|
||||
|
||||
void def() {
|
||||
for (int i = 0; i < 1000; ++i)
|
||||
CLOG(INFO, "first") << "This is from first " << i;
|
||||
}
|
||||
|
||||
void second() {
|
||||
for (int i = 0; i < 1000; ++i)
|
||||
CLOG(INFO, "second") << "This is from second" << i;
|
||||
}
|
||||
|
||||
int main(int,char**){
|
||||
el::Loggers::addFlag(el::LoggingFlag::CreateLoggerAutomatically);
|
||||
|
||||
el::Configurations confFromFile("../default-logger.conf");
|
||||
|
||||
el::Loggers::setDefaultConfigurations(confFromFile, true);
|
||||
|
||||
LOG(INFO)<<"The program has started!";
|
||||
|
||||
std::thread t1(def);
|
||||
std::thread t2(second);
|
||||
|
||||
t1.join();
|
||||
t2.join();
|
||||
|
||||
LOG(INFO) << "Shutting down.";
|
||||
return 0;
|
||||
}
|
51
samples/STL/multi-loggers-with-async.cpp
Normal file
51
samples/STL/multi-loggers-with-async.cpp
Normal file
@ -0,0 +1,51 @@
|
||||
//
|
||||
// This file is part of Easylogging++ samples
|
||||
//
|
||||
// Revision 1.0
|
||||
//
|
||||
|
||||
#include <chrono>
|
||||
#include <thread>
|
||||
#include <future>
|
||||
#include "easylogging++.h"
|
||||
|
||||
INITIALIZE_EASYLOGGINGPP
|
||||
|
||||
void f() {
|
||||
std::async(std::launch::async, [&]() {
|
||||
std::cout << "[internal] inside async()" << std::endl;
|
||||
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||
LOG(INFO) << "This is from async";
|
||||
});
|
||||
}
|
||||
|
||||
class MyHandler : public el::LogDispatchCallback {
|
||||
public:
|
||||
void handle(const el::LogDispatchData* d) {
|
||||
std::cout << "Message: " << d->logMessage()->message() << " [logger: " << d->logMessage()->logger()->id() << "]" << std::endl;
|
||||
if (d->logMessage()->logger()->id() != "default") {
|
||||
std::cout << "[internal] calling f()" << std::endl;
|
||||
f();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
int main(int,char**){
|
||||
el::Loggers::addFlag(el::LoggingFlag::CreateLoggerAutomatically);
|
||||
// el::Helpers::uninstallLogDispatchCallback<el::base::DefaultLogDispatchCallback>("DefaultLogDispatchCallback");
|
||||
el::Helpers::installLogDispatchCallback<MyHandler>("MyHandler");
|
||||
|
||||
LOG(INFO)<<"The program has started!";
|
||||
CLOG(INFO, "frommain") << "THis is another";
|
||||
|
||||
std::thread t1([](){
|
||||
LOG(INFO) << "This is from thread";
|
||||
});
|
||||
|
||||
t1.join();
|
||||
|
||||
LOG(INFO) << "Shutting down.";
|
||||
return 0;
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
// This file is part of Easylogging++ samples
|
||||
//
|
||||
// Sample to demonstrate using occasionals and other hit counts based logging
|
||||
// Sample to demonstrate using occasional and other hit count based logging
|
||||
//
|
||||
// Revision 1.2
|
||||
// @author mkhan3189
|
||||
|
@ -1,5 +1,5 @@
|
||||
* GLOBAL:
|
||||
FORMAT = "%datetime | %level | %msg"
|
||||
FORMAT = "%datetime | %level | %logger | %msg"
|
||||
FILENAME = "/tmp/logs/myeasylog-configuration.cpp.log"
|
||||
ENABLED = true
|
||||
TO_FILE = true
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
You can use this sample to send your log messages to network as requested by many users. We are not able to add it to the library as this will require some stuffs to choose what network library to use.
|
||||
|
||||
This sample uses `asio` in `boost_system`
|
||||
This sample uses `boost::asio`
|
||||
|
||||
## Run
|
||||
|
||||
@ -13,17 +13,15 @@ mkdir bin
|
||||
sh compile.sh network-logger.sh
|
||||
```
|
||||
|
||||
Run a server (we are using netcat on mac for test purposes) on a different terminal
|
||||
Run a server (we are using netcat on mac for demo) on a new tab in your terminal
|
||||
|
||||
```
|
||||
nc -l 9090
|
||||
nc -k -l 9090
|
||||
```
|
||||
|
||||
Now run `./bin/network-logger`
|
||||
|
||||
|
||||
## More
|
||||
|
||||
You may need `ELPP_NO_LOG_TO_FILE` and `ELPP_NO_DEFAULT_LOG_FILE` depending on your needs.
|
||||
Please refer to [doc](https://github.com/amrayn/easyloggingpp#configuration-macros) for further details on macros
|
||||
|
||||
Please refer to [doc](https://github.com/muflihun/easyloggingpp#configuration-macros) for further details on macros
|
||||
|
@ -17,7 +17,11 @@ fi
|
||||
|
||||
echo "Compiling... [$FILE]"
|
||||
|
||||
COMPILE_LINE="$COMPILER $FILE easylogging++.cc -o bin/$FILE.bin $CXX_STD -std=c++11 -pthread -I /opt/local/include -L/opt/local/lib -lboost_system -Wno-deprecated-declarations"
|
||||
if [ ! -d "bin" ];then
|
||||
mkdir bin
|
||||
fi;
|
||||
|
||||
COMPILE_LINE="$COMPILER $FILE easylogging++.cc -o bin/$FILE.bin $CXX_STD -pthread -lboost_system"
|
||||
|
||||
echo " $COMPILE_LINE"
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
// Revision 1.0
|
||||
// @author mkhan3189
|
||||
//
|
||||
// Compile: g++ network-logger.cpp easylogging++.cc -o bin/network-logger.cpp.bin -std=c++11 -pthread -I /opt/local/include -L/opt/local/lib -lboost_system -Wno-deprecated-declarations
|
||||
// Compile: sh compile.sh network-logger.cpp
|
||||
//
|
||||
|
||||
#include "easylogging++.h"
|
||||
@ -16,16 +16,16 @@
|
||||
INITIALIZE_EASYLOGGINGPP
|
||||
|
||||
|
||||
// Following Client struct adapted from http://stackoverflow.com/questions/27672591/boost-asio-send-and-receive-messages
|
||||
struct Client
|
||||
class Client
|
||||
{
|
||||
boost::asio::io_service& io_service;
|
||||
boost::asio::io_service* io_service;
|
||||
boost::asio::ip::tcp::socket socket;
|
||||
|
||||
Client(boost::asio::io_service& svc, std::string const& host, std::string const& port)
|
||||
: io_service(svc), socket(io_service)
|
||||
public:
|
||||
Client(boost::asio::io_service* svc, const std::string& host, const std::string& port)
|
||||
: io_service(svc), socket(*io_service)
|
||||
{
|
||||
boost::asio::ip::tcp::resolver resolver(io_service);
|
||||
boost::asio::ip::tcp::resolver resolver(*io_service);
|
||||
boost::asio::ip::tcp::resolver::iterator endpoint = resolver.resolve(boost::asio::ip::tcp::resolver::query(host, port));
|
||||
boost::asio::connect(this->socket, endpoint);
|
||||
};
|
||||
@ -38,46 +38,39 @@ struct Client
|
||||
class NetworkDispatcher : public el::LogDispatchCallback
|
||||
{
|
||||
public:
|
||||
// Setters
|
||||
void setHost(const std::string& host) {
|
||||
m_host = host;
|
||||
}
|
||||
void setPort(int port) {
|
||||
m_port = port;
|
||||
}
|
||||
void updateServer(const std::string& host, int port) {
|
||||
m_client = std::unique_ptr<Client>(new Client(&m_svc, host, std::to_string(port)));
|
||||
}
|
||||
protected:
|
||||
void handle(const el::LogDispatchData* data) noexcept override
|
||||
{
|
||||
m_data = data;
|
||||
// Dispatch using default log builder of logger
|
||||
dispatch(m_data->logMessage()->logger()->logBuilder()->build(m_data->logMessage(),
|
||||
m_data->dispatchAction() == el::base::DispatchAction::NormalLog));
|
||||
void handle(const el::LogDispatchData* data) noexcept override {
|
||||
m_data = data;
|
||||
// Dispatch using default log builder of logger
|
||||
dispatch(m_data->logMessage()->logger()->logBuilder()->build(m_data->logMessage(),
|
||||
m_data->dispatchAction() == el::base::DispatchAction::NormalLog));
|
||||
}
|
||||
private:
|
||||
const el::LogDispatchData* m_data;
|
||||
std::string m_host;
|
||||
int m_port;
|
||||
boost::asio::io_service m_svc;
|
||||
std::unique_ptr<Client> m_client;
|
||||
|
||||
void dispatch(el::base::type::string_t&& logLine) noexcept
|
||||
{
|
||||
boost::asio::io_service svc;
|
||||
Client client(svc, m_host, std::to_string(m_port));
|
||||
|
||||
client.send(logLine);
|
||||
m_client->send(logLine);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
int main() {
|
||||
el::Helpers::installLogDispatchCallback<NetworkDispatcher>("NetworkDispatcher");
|
||||
// Set server params
|
||||
NetworkDispatcher* dispatcher = el::Helpers::logDispatchCallback<NetworkDispatcher>("NetworkDispatcher");
|
||||
dispatcher->setEnabled(true);
|
||||
dispatcher->setHost("127.0.0.1");
|
||||
dispatcher->setPort(9090);
|
||||
|
||||
// Start logging and normal program...
|
||||
LOG(INFO) << "First network log";
|
||||
|
||||
// You can even use a different logger, say "network" and send using a different log pattern
|
||||
}
|
||||
el::Helpers::installLogDispatchCallback<NetworkDispatcher>("NetworkDispatcher");
|
||||
// you can uninstall default one by
|
||||
// el::Helpers::uninstallLogDispatchCallback<el::base::DefaultLogDispatchCallback>("DefaultLogDispatchCallback");
|
||||
// Set server params
|
||||
NetworkDispatcher* dispatcher = el::Helpers::logDispatchCallback<NetworkDispatcher>("NetworkDispatcher");
|
||||
dispatcher->setEnabled(true);
|
||||
dispatcher->updateServer("127.0.0.1", 9090);
|
||||
|
||||
// Start logging and normal program...
|
||||
LOG(INFO) << "First network log";
|
||||
|
||||
// You can even use a different logger, say "network" and send using a different log pattern
|
||||
}
|
||||
|
@ -1,16 +1,16 @@
|
||||
//
|
||||
// Bismillah ar-Rahmaan ar-Raheem
|
||||
//
|
||||
// Easylogging++ v9.95.0
|
||||
// Easylogging++ v9.96.7
|
||||
// Cross-platform logging library for C++ applications
|
||||
//
|
||||
// Copyright (c) 2017 muflihun.com
|
||||
// Copyright (c) 2012-2018 Amrayn Web Services
|
||||
// Copyright (c) 2012-2018 @abumusamq
|
||||
//
|
||||
// This library is released under the MIT Licence.
|
||||
// http://labs.muflihun.com/easyloggingpp/licence.php
|
||||
// https://github.com/amrayn/easyloggingpp/blob/master/LICENSE
|
||||
//
|
||||
// https://github.com/muflihun/easyloggingpp
|
||||
// https://muflihun.github.io/easyloggingpp
|
||||
// https://amrayn.com
|
||||
// http://muflihun.com
|
||||
//
|
||||
|
||||
@ -22,8 +22,95 @@ INITIALIZE_EASYLOGGINGPP
|
||||
|
||||
namespace el {
|
||||
|
||||
// el::base::utils
|
||||
// el::base
|
||||
namespace base {
|
||||
// el::base::consts
|
||||
namespace consts {
|
||||
|
||||
// Level log values - These are values that are replaced in place of %level format specifier
|
||||
// Extra spaces after format specifiers are only for readability purposes in log files
|
||||
static const base::type::char_t* kInfoLevelLogValue = ELPP_LITERAL("INFO");
|
||||
static const base::type::char_t* kDebugLevelLogValue = ELPP_LITERAL("DEBUG");
|
||||
static const base::type::char_t* kWarningLevelLogValue = ELPP_LITERAL("WARNING");
|
||||
static const base::type::char_t* kErrorLevelLogValue = ELPP_LITERAL("ERROR");
|
||||
static const base::type::char_t* kFatalLevelLogValue = ELPP_LITERAL("FATAL");
|
||||
static const base::type::char_t* kVerboseLevelLogValue =
|
||||
ELPP_LITERAL("VERBOSE"); // will become VERBOSE-x where x = verbose level
|
||||
static const base::type::char_t* kTraceLevelLogValue = ELPP_LITERAL("TRACE");
|
||||
static const base::type::char_t* kInfoLevelShortLogValue = ELPP_LITERAL("I");
|
||||
static const base::type::char_t* kDebugLevelShortLogValue = ELPP_LITERAL("D");
|
||||
static const base::type::char_t* kWarningLevelShortLogValue = ELPP_LITERAL("W");
|
||||
static const base::type::char_t* kErrorLevelShortLogValue = ELPP_LITERAL("E");
|
||||
static const base::type::char_t* kFatalLevelShortLogValue = ELPP_LITERAL("F");
|
||||
static const base::type::char_t* kVerboseLevelShortLogValue = ELPP_LITERAL("V");
|
||||
static const base::type::char_t* kTraceLevelShortLogValue = ELPP_LITERAL("T");
|
||||
// Format specifiers - These are used to define log format
|
||||
static const base::type::char_t* kAppNameFormatSpecifier = ELPP_LITERAL("%app");
|
||||
static const base::type::char_t* kLoggerIdFormatSpecifier = ELPP_LITERAL("%logger");
|
||||
static const base::type::char_t* kThreadIdFormatSpecifier = ELPP_LITERAL("%thread");
|
||||
static const base::type::char_t* kSeverityLevelFormatSpecifier = ELPP_LITERAL("%level");
|
||||
static const base::type::char_t* kSeverityLevelShortFormatSpecifier = ELPP_LITERAL("%levshort");
|
||||
static const base::type::char_t* kDateTimeFormatSpecifier = ELPP_LITERAL("%datetime");
|
||||
static const base::type::char_t* kLogFileFormatSpecifier = ELPP_LITERAL("%file");
|
||||
static const base::type::char_t* kLogFileBaseFormatSpecifier = ELPP_LITERAL("%fbase");
|
||||
static const base::type::char_t* kLogLineFormatSpecifier = ELPP_LITERAL("%line");
|
||||
static const base::type::char_t* kLogLocationFormatSpecifier = ELPP_LITERAL("%loc");
|
||||
static const base::type::char_t* kLogFunctionFormatSpecifier = ELPP_LITERAL("%func");
|
||||
static const base::type::char_t* kCurrentUserFormatSpecifier = ELPP_LITERAL("%user");
|
||||
static const base::type::char_t* kCurrentHostFormatSpecifier = ELPP_LITERAL("%host");
|
||||
static const base::type::char_t* kMessageFormatSpecifier = ELPP_LITERAL("%msg");
|
||||
static const base::type::char_t* kVerboseLevelFormatSpecifier = ELPP_LITERAL("%vlevel");
|
||||
static const char* kDateTimeFormatSpecifierForFilename = "%datetime";
|
||||
// Date/time
|
||||
static const char* kDays[7] = { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" };
|
||||
static const char* kDaysAbbrev[7] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };
|
||||
static const char* kMonths[12] = { "January", "February", "March", "April", "May", "June", "July", "August",
|
||||
"September", "October", "November", "December"
|
||||
};
|
||||
static const char* kMonthsAbbrev[12] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
|
||||
static const char* kDefaultDateTimeFormat = "%Y-%M-%d %H:%m:%s,%g";
|
||||
static const char* kDefaultDateTimeFormatInFilename = "%Y-%M-%d_%H-%m";
|
||||
static const int kYearBase = 1900;
|
||||
static const char* kAm = "AM";
|
||||
static const char* kPm = "PM";
|
||||
// Miscellaneous constants
|
||||
|
||||
static const char* kNullPointer = "nullptr";
|
||||
#if ELPP_VARIADIC_TEMPLATES_SUPPORTED
|
||||
#endif // ELPP_VARIADIC_TEMPLATES_SUPPORTED
|
||||
static const base::type::VerboseLevel kMaxVerboseLevel = 9;
|
||||
static const char* kUnknownUser = "unknown-user";
|
||||
static const char* kUnknownHost = "unknown-host";
|
||||
|
||||
|
||||
//---------------- DEFAULT LOG FILE -----------------------
|
||||
|
||||
#if defined(ELPP_NO_DEFAULT_LOG_FILE)
|
||||
# if ELPP_OS_UNIX
|
||||
static const char* kDefaultLogFile = "/dev/null";
|
||||
# elif ELPP_OS_WINDOWS
|
||||
static const char* kDefaultLogFile = "nul";
|
||||
# endif // ELPP_OS_UNIX
|
||||
#elif defined(ELPP_DEFAULT_LOG_FILE)
|
||||
static const char* kDefaultLogFile = ELPP_DEFAULT_LOG_FILE;
|
||||
#else
|
||||
static const char* kDefaultLogFile = "myeasylog.log";
|
||||
#endif // defined(ELPP_NO_DEFAULT_LOG_FILE)
|
||||
|
||||
|
||||
#if !defined(ELPP_DISABLE_LOG_FILE_FROM_ARG)
|
||||
static const char* kDefaultLogFileParam = "--default-log-file";
|
||||
#endif // !defined(ELPP_DISABLE_LOG_FILE_FROM_ARG)
|
||||
#if defined(ELPP_LOGGING_FLAGS_FROM_ARG)
|
||||
static const char* kLoggingFlagsParam = "--logging-flags";
|
||||
#endif // defined(ELPP_LOGGING_FLAGS_FROM_ARG)
|
||||
static const char* kValidLoggerIdSymbols =
|
||||
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._";
|
||||
static const char* kConfigurationComment = "##";
|
||||
static const char* kConfigurationLevel = "*";
|
||||
static const char* kConfigurationLoggerId = "--";
|
||||
}
|
||||
// el::base::utils
|
||||
namespace utils {
|
||||
|
||||
/// @brief Aborts application due with user-defined status
|
||||
@ -205,7 +292,7 @@ Configurations::Configurations(const std::string& configurationFile, bool useDef
|
||||
}
|
||||
|
||||
bool Configurations::parseFromFile(const std::string& configurationFile, Configurations* base) {
|
||||
// We initial assertion with true because if we have assertion diabled, we want to pass this
|
||||
// We initial assertion with true because if we have assertion disabled, we want to pass this
|
||||
// check and if assertion is enabled we will have values re-assigned any way.
|
||||
bool assertionPassed = true;
|
||||
ELPP_ASSERT((assertionPassed = base::utils::File::pathExists(configurationFile.c_str(), true)) == true,
|
||||
@ -276,11 +363,7 @@ void Configurations::set(Configuration* conf) {
|
||||
|
||||
void Configurations::setToDefault(void) {
|
||||
setGlobally(ConfigurationType::Enabled, std::string("true"), true);
|
||||
#if !defined(ELPP_NO_DEFAULT_LOG_FILE)
|
||||
setGlobally(ConfigurationType::Filename, std::string(base::consts::kDefaultLogFile), true);
|
||||
#else
|
||||
ELPP_UNUSED(base::consts::kDefaultLogFile);
|
||||
#endif // !defined(ELPP_NO_DEFAULT_LOG_FILE)
|
||||
#if defined(ELPP_NO_LOG_TO_FILE)
|
||||
setGlobally(ConfigurationType::ToFile, std::string("false"), true);
|
||||
#else
|
||||
@ -309,9 +392,7 @@ void Configurations::setRemainingToDefault(void) {
|
||||
#else
|
||||
unsafeSetIfNotExist(Level::Global, ConfigurationType::Enabled, std::string("true"));
|
||||
#endif // defined(ELPP_NO_LOG_TO_FILE)
|
||||
#if !defined(ELPP_NO_DEFAULT_LOG_FILE)
|
||||
unsafeSetIfNotExist(Level::Global, ConfigurationType::Filename, std::string(base::consts::kDefaultLogFile));
|
||||
#endif // !defined(ELPP_NO_DEFAULT_LOG_FILE)
|
||||
unsafeSetIfNotExist(Level::Global, ConfigurationType::ToStandardOutput, std::string("true"));
|
||||
unsafeSetIfNotExist(Level::Global, ConfigurationType::SubsecondPrecision, std::string("3"));
|
||||
unsafeSetIfNotExist(Level::Global, ConfigurationType::PerformanceTracking, std::string("true"));
|
||||
@ -518,7 +599,7 @@ void LogBuilder::convertToColoredOutput(base::type::string_t* logLine, Level lev
|
||||
|
||||
// Logger
|
||||
|
||||
Logger::Logger(const std::string& id, base::LogStreamsReferenceMap* logStreamsReference) :
|
||||
Logger::Logger(const std::string& id, base::LogStreamsReferenceMapPtr logStreamsReference) :
|
||||
m_id(id),
|
||||
m_typedConfigurations(nullptr),
|
||||
m_parentApplicationName(std::string()),
|
||||
@ -528,7 +609,7 @@ Logger::Logger(const std::string& id, base::LogStreamsReferenceMap* logStreamsRe
|
||||
}
|
||||
|
||||
Logger::Logger(const std::string& id, const Configurations& configurations,
|
||||
base::LogStreamsReferenceMap* logStreamsReference) :
|
||||
base::LogStreamsReferenceMapPtr logStreamsReference) :
|
||||
m_id(id),
|
||||
m_typedConfigurations(nullptr),
|
||||
m_parentApplicationName(std::string()),
|
||||
@ -569,7 +650,6 @@ void Logger::configure(const Configurations& configurations) {
|
||||
if (m_typedConfigurations != nullptr) {
|
||||
Configurations* c = const_cast<Configurations*>(m_typedConfigurations->configurations());
|
||||
if (c->hasConfiguration(Level::Global, ConfigurationType::Filename)) {
|
||||
// This check is definitely needed for cases like ELPP_NO_DEFAULT_LOG_FILE
|
||||
flush();
|
||||
}
|
||||
}
|
||||
@ -613,10 +693,11 @@ void Logger::flush(Level level, base::type::fstream_t* fs) {
|
||||
}
|
||||
if (fs != nullptr) {
|
||||
fs->flush();
|
||||
std::map<Level, unsigned int>::iterator iter = m_unflushedCount.find(level);
|
||||
std::unordered_map<Level, unsigned int>::iterator iter = m_unflushedCount.find(level);
|
||||
if (iter != m_unflushedCount.end()) {
|
||||
iter->second = 0;
|
||||
}
|
||||
Helpers::validateFileRolling(this, level);
|
||||
}
|
||||
}
|
||||
|
||||
@ -675,10 +756,9 @@ std::size_t File::getSizeOfFile(base::type::fstream_t* fs) {
|
||||
if (fs == nullptr) {
|
||||
return 0;
|
||||
}
|
||||
std::streampos currPos = fs->tellg();
|
||||
fs->seekg(0, fs->end);
|
||||
// Since the file stream is appended to or truncated, the current
|
||||
// offset is the file size.
|
||||
std::size_t size = static_cast<std::size_t>(fs->tellg());
|
||||
fs->seekg(currPos);
|
||||
return size;
|
||||
}
|
||||
|
||||
@ -714,22 +794,22 @@ bool File::createPath(const std::string& path) {
|
||||
if (path[0] == '/') {
|
||||
builtPath = "/";
|
||||
}
|
||||
currPath = STRTOK(currPath, base::consts::kFilePathSeperator, 0);
|
||||
currPath = STRTOK(currPath, base::consts::kFilePathSeparator, 0);
|
||||
#elif ELPP_OS_WINDOWS
|
||||
// Use secure functions API
|
||||
char* nextTok_ = nullptr;
|
||||
currPath = STRTOK(currPath, base::consts::kFilePathSeperator, &nextTok_);
|
||||
currPath = STRTOK(currPath, base::consts::kFilePathSeparator, &nextTok_);
|
||||
ELPP_UNUSED(nextTok_);
|
||||
#endif // ELPP_OS_UNIX
|
||||
while (currPath != nullptr) {
|
||||
builtPath.append(currPath);
|
||||
builtPath.append(base::consts::kFilePathSeperator);
|
||||
builtPath.append(base::consts::kFilePathSeparator);
|
||||
#if ELPP_OS_UNIX
|
||||
status = mkdir(builtPath.c_str(), ELPP_LOG_PERMS);
|
||||
currPath = STRTOK(nullptr, base::consts::kFilePathSeperator, 0);
|
||||
currPath = STRTOK(nullptr, base::consts::kFilePathSeparator, 0);
|
||||
#elif ELPP_OS_WINDOWS
|
||||
status = _mkdir(builtPath.c_str());
|
||||
currPath = STRTOK(nullptr, base::consts::kFilePathSeperator, &nextTok_);
|
||||
currPath = STRTOK(nullptr, base::consts::kFilePathSeparator, &nextTok_);
|
||||
#endif // ELPP_OS_UNIX
|
||||
}
|
||||
if (status == -1) {
|
||||
@ -850,7 +930,7 @@ void Str::replaceFirstWithEscape(base::type::string_t& str, const base::type::st
|
||||
std::size_t foundAt = base::type::string_t::npos;
|
||||
while ((foundAt = str.find(replaceWhat, foundAt + 1)) != base::type::string_t::npos) {
|
||||
if (foundAt > 0 && str[foundAt - 1] == base::consts::kFormatSpecifierChar) {
|
||||
str.erase(foundAt > 0 ? foundAt - 1 : 0, 1);
|
||||
str.erase(foundAt - 1, 1);
|
||||
++foundAt;
|
||||
} else {
|
||||
str.replace(foundAt, replaceWhat.length(), replaceWith);
|
||||
@ -933,7 +1013,7 @@ char* Str::clearBuff(char buff[], std::size_t lim) {
|
||||
return buff;
|
||||
}
|
||||
|
||||
/// @brief Converst wchar* to char*
|
||||
/// @brief Converts wchar* to char*
|
||||
/// NOTE: Need to free return value after use!
|
||||
char* Str::wcharPtrToCharPtr(const wchar_t* line) {
|
||||
std::size_t len_ = wcslen(line) + 1;
|
||||
@ -997,8 +1077,9 @@ const std::string OS::getBashOutput(const char* command) {
|
||||
char hBuff[4096];
|
||||
if (fgets(hBuff, sizeof(hBuff), proc) != nullptr) {
|
||||
pclose(proc);
|
||||
if (hBuff[strlen(hBuff) - 1] == '\n') {
|
||||
hBuff[strlen(hBuff) - 1] = '\0';
|
||||
const std::size_t buffLen = strlen(hBuff);
|
||||
if (buffLen > 0 && hBuff[buffLen - 1] == '\n') {
|
||||
hBuff[buffLen - 1] = '\0';
|
||||
}
|
||||
return std::string(hBuff);
|
||||
} else {
|
||||
@ -1272,7 +1353,7 @@ bool CommandLineArgs::hasParamWithValue(const char* paramKey) const {
|
||||
}
|
||||
|
||||
const char* CommandLineArgs::getParamValue(const char* paramKey) const {
|
||||
std::map<std::string, std::string>::const_iterator iter = m_paramsWithValue.find(std::string(paramKey));
|
||||
std::unordered_map<std::string, std::string>::const_iterator iter = m_paramsWithValue.find(std::string(paramKey));
|
||||
return iter != m_paramsWithValue.end() ? iter->second.c_str() : "";
|
||||
}
|
||||
|
||||
@ -1418,7 +1499,7 @@ void LogFormat::parseFromFormat(const base::type::string_t& userFormat) {
|
||||
if (hasFlag(flag)) {
|
||||
// If we already have flag we remove the escape chars so that '%%' is turned to '%'
|
||||
// even after specifier resolution - this is because we only replaceFirst specifier
|
||||
formatCopy.erase(foundAt > 0 ? foundAt - 1 : 0, 1);
|
||||
formatCopy.erase(foundAt - 1, 1);
|
||||
++foundAt;
|
||||
}
|
||||
} else {
|
||||
@ -1443,7 +1524,7 @@ void LogFormat::parseFromFormat(const base::type::string_t& userFormat) {
|
||||
// For date/time we need to extract user's date format first
|
||||
std::size_t dateIndex = std::string::npos;
|
||||
if ((dateIndex = formatCopy.find(base::consts::kDateTimeFormatSpecifier)) != std::string::npos) {
|
||||
while (dateIndex > 0 && formatCopy[dateIndex - 1] == base::consts::kFormatSpecifierChar) {
|
||||
while (dateIndex != std::string::npos && dateIndex > 0 && formatCopy[dateIndex - 1] == base::consts::kFormatSpecifierChar) {
|
||||
dateIndex = formatCopy.find(base::consts::kDateTimeFormatSpecifier, dateIndex + 1);
|
||||
}
|
||||
if (dateIndex != std::string::npos) {
|
||||
@ -1534,7 +1615,7 @@ void LogFormat::updateFormatSpec(void) {
|
||||
// TypedConfigurations
|
||||
|
||||
TypedConfigurations::TypedConfigurations(Configurations* configurations,
|
||||
base::LogStreamsReferenceMap* logStreamsReference) {
|
||||
LogStreamsReferenceMapPtr logStreamsReference) {
|
||||
m_configurations = configurations;
|
||||
m_logStreamsReference = logStreamsReference;
|
||||
build(m_configurations);
|
||||
@ -1610,7 +1691,7 @@ void TypedConfigurations::build(Configurations* configurations) {
|
||||
// We do not yet configure filename but we will configure in another
|
||||
// loop. This is because if file cannot be created, we will force ToFile
|
||||
// to be false. Because configuring logger is not necessarily performance
|
||||
// sensative operation, we can live with another loop; (by the way this loop
|
||||
// sensitive operation, we can live with another loop; (by the way this loop
|
||||
// is not very heavy either)
|
||||
} else if (conf->configurationType() == ConfigurationType::Format) {
|
||||
setValue(conf->level(), base::LogFormat(conf->level(),
|
||||
@ -1621,10 +1702,11 @@ void TypedConfigurations::build(Configurations* configurations) {
|
||||
} else if (conf->configurationType() == ConfigurationType::PerformanceTracking) {
|
||||
setValue(Level::Global, getBool(conf->value()), &m_performanceTrackingMap);
|
||||
} else if (conf->configurationType() == ConfigurationType::MaxLogFileSize) {
|
||||
setValue(conf->level(), static_cast<std::size_t>(getULong(conf->value())), &m_maxLogFileSizeMap);
|
||||
#if !defined(ELPP_NO_DEFAULT_LOG_FILE)
|
||||
withFileSizeLimit.push_back(conf);
|
||||
#endif // !defined(ELPP_NO_DEFAULT_LOG_FILE)
|
||||
auto v = getULong(conf->value());
|
||||
setValue(conf->level(), static_cast<std::size_t>(v), &m_maxLogFileSizeMap);
|
||||
if (v != 0) {
|
||||
withFileSizeLimit.push_back(conf);
|
||||
}
|
||||
} else if (conf->configurationType() == ConfigurationType::LogFlushThreshold) {
|
||||
setValue(conf->level(), static_cast<std::size_t>(getULong(conf->value())), &m_logFlushThresholdMap);
|
||||
}
|
||||
@ -1698,18 +1780,12 @@ std::string TypedConfigurations::resolveFilename(const std::string& filename) {
|
||||
}
|
||||
|
||||
void TypedConfigurations::insertFile(Level level, const std::string& fullFilename) {
|
||||
#if defined(ELPP_NO_LOG_TO_FILE)
|
||||
setValue(level, false, &m_toFileMap);
|
||||
ELPP_UNUSED(fullFilename);
|
||||
m_fileStreamMap.insert(std::make_pair(level, base::FileStreamPtr(nullptr)));
|
||||
return;
|
||||
#endif
|
||||
std::string resolvedFilename = resolveFilename(fullFilename);
|
||||
if (resolvedFilename.empty()) {
|
||||
std::cerr << "Could not load empty file for logging, please re-check your configurations for level ["
|
||||
<< LevelHelper::convertToString(level) << "]";
|
||||
}
|
||||
std::string filePath = base::utils::File::extractPathFromFilename(resolvedFilename, base::consts::kFilePathSeperator);
|
||||
std::string filePath = base::utils::File::extractPathFromFilename(resolvedFilename, base::consts::kFilePathSeparator);
|
||||
if (filePath.size() < resolvedFilename.size()) {
|
||||
base::utils::File::createPath(filePath);
|
||||
}
|
||||
@ -1809,6 +1885,7 @@ bool RegisteredHitCounters::validateNTimes(const char* filename, base::type::Lin
|
||||
RegisteredLoggers::RegisteredLoggers(const LogBuilderPtr& defaultLogBuilder) :
|
||||
m_defaultLogBuilder(defaultLogBuilder) {
|
||||
m_defaultConfigurations.setToDefault();
|
||||
m_logStreamsReference = std::make_shared<base::LogStreamsReferenceMap>();
|
||||
}
|
||||
|
||||
Logger* RegisteredLoggers::get(const std::string& id, bool forceCreation) {
|
||||
@ -1820,7 +1897,7 @@ Logger* RegisteredLoggers::get(const std::string& id, bool forceCreation) {
|
||||
ELPP_ASSERT(validId, "Invalid logger ID [" << id << "]. Not registering this logger.");
|
||||
return nullptr;
|
||||
}
|
||||
logger_ = new Logger(id, m_defaultConfigurations, &m_logStreamsReference);
|
||||
logger_ = new Logger(id, m_defaultConfigurations, m_logStreamsReference);
|
||||
logger_->m_logBuilder = m_defaultLogBuilder;
|
||||
registerNew(id, logger_);
|
||||
LoggerRegistrationCallback* callback = nullptr;
|
||||
@ -1839,8 +1916,10 @@ bool RegisteredLoggers::remove(const std::string& id) {
|
||||
if (id == base::consts::kDefaultLoggerId) {
|
||||
return false;
|
||||
}
|
||||
// get has internal lock
|
||||
Logger* logger = base::utils::Registry<Logger, std::string>::get(id);
|
||||
if (logger != nullptr) {
|
||||
// unregister has internal lock
|
||||
unregister(logger);
|
||||
}
|
||||
return true;
|
||||
@ -1848,8 +1927,8 @@ bool RegisteredLoggers::remove(const std::string& id) {
|
||||
|
||||
void RegisteredLoggers::unsafeFlushAll(void) {
|
||||
ELPP_INTERNAL_INFO(1, "Flushing all log files");
|
||||
for (base::LogStreamsReferenceMap::iterator it = m_logStreamsReference.begin();
|
||||
it != m_logStreamsReference.end(); ++it) {
|
||||
for (base::LogStreamsReferenceMap::iterator it = m_logStreamsReference->begin();
|
||||
it != m_logStreamsReference->end(); ++it) {
|
||||
if (it->second.get() == nullptr) continue;
|
||||
it->second->flush();
|
||||
}
|
||||
@ -1948,7 +2027,7 @@ bool VRegistry::allowed(base::type::VerboseLevel vlevel, const char* file) {
|
||||
} else {
|
||||
char baseFilename[base::consts::kSourceFilenameMaxLength] = "";
|
||||
base::utils::File::buildBaseFilename(file, baseFilename);
|
||||
std::map<std::string, base::type::VerboseLevel>::iterator it = m_modules.begin();
|
||||
std::unordered_map<std::string, base::type::VerboseLevel>::iterator it = m_modules.begin();
|
||||
for (; it != m_modules.end(); ++it) {
|
||||
if (base::utils::Str::wildCardMatch(baseFilename, it->first.c_str())) {
|
||||
return vlevel <= it->second;
|
||||
@ -1989,20 +2068,26 @@ Storage::Storage(const LogBuilderPtr& defaultLogBuilder) :
|
||||
m_registeredLoggers(new base::RegisteredLoggers(defaultLogBuilder)),
|
||||
m_flags(ELPP_DEFAULT_LOGGING_FLAGS),
|
||||
m_vRegistry(new base::VRegistry(0, &m_flags)),
|
||||
|
||||
#if ELPP_ASYNC_LOGGING
|
||||
m_asyncLogQueue(new base::AsyncLogQueue()),
|
||||
m_asyncDispatchWorker(asyncDispatchWorker),
|
||||
#endif // ELPP_ASYNC_LOGGING
|
||||
|
||||
m_preRollOutCallback(base::defaultPreRollOutCallback) {
|
||||
// Register default logger
|
||||
m_registeredLoggers->get(std::string(base::consts::kDefaultLoggerId));
|
||||
// We register default logger anyway (worse case it's not going to register) just in case
|
||||
m_registeredLoggers->get("default");
|
||||
|
||||
#if defined(ELPP_FEATURE_ALL) || defined(ELPP_FEATURE_PERFORMANCE_TRACKING)
|
||||
// Register performance logger and reconfigure format
|
||||
Logger* performanceLogger = m_registeredLoggers->get(std::string(base::consts::kPerformanceLoggerId));
|
||||
m_registeredLoggers->get("performance");
|
||||
performanceLogger->configurations()->setGlobally(ConfigurationType::Format, std::string("%datetime %level %msg"));
|
||||
performanceLogger->reconfigure();
|
||||
#endif // defined(ELPP_FEATURE_ALL) || defined(ELPP_FEATURE_PERFORMANCE_TRACKING)
|
||||
|
||||
#if defined(ELPP_SYSLOG)
|
||||
// Register syslog logger and reconfigure format
|
||||
Logger* sysLogLogger = m_registeredLoggers->get(std::string(base::consts::kSysLogLoggerId));
|
||||
@ -2045,7 +2130,7 @@ Storage::~Storage(void) {
|
||||
}
|
||||
|
||||
bool Storage::hasCustomFormatSpecifier(const char* formatSpecifier) {
|
||||
base::threading::ScopedLock scopedLock(lock());
|
||||
base::threading::ScopedLock scopedLock(customFormatSpecifiersLock());
|
||||
return std::find(m_customFormatSpecifiers.begin(), m_customFormatSpecifiers.end(),
|
||||
formatSpecifier) != m_customFormatSpecifiers.end();
|
||||
}
|
||||
@ -2054,12 +2139,12 @@ void Storage::installCustomFormatSpecifier(const CustomFormatSpecifier& customFo
|
||||
if (hasCustomFormatSpecifier(customFormatSpecifier.formatSpecifier())) {
|
||||
return;
|
||||
}
|
||||
base::threading::ScopedLock scopedLock(lock());
|
||||
base::threading::ScopedLock scopedLock(customFormatSpecifiersLock());
|
||||
m_customFormatSpecifiers.push_back(customFormatSpecifier);
|
||||
}
|
||||
|
||||
bool Storage::uninstallCustomFormatSpecifier(const char* formatSpecifier) {
|
||||
base::threading::ScopedLock scopedLock(lock());
|
||||
base::threading::ScopedLock scopedLock(customFormatSpecifiersLock());
|
||||
std::vector<CustomFormatSpecifier>::iterator it = std::find(m_customFormatSpecifiers.begin(),
|
||||
m_customFormatSpecifiers.end(), formatSpecifier);
|
||||
if (it != m_customFormatSpecifiers.end() && strcmp(formatSpecifier, it->formatSpecifier()) == 0) {
|
||||
@ -2097,9 +2182,35 @@ void Storage::setApplicationArguments(int argc, char** argv) {
|
||||
#endif // defined(ELPP_LOGGING_FLAGS_FROM_ARG)
|
||||
}
|
||||
|
||||
} // namespace base
|
||||
|
||||
// LogDispatchCallback
|
||||
#if defined(ELPP_THREAD_SAFE)
|
||||
void LogDispatchCallback::handle(const LogDispatchData* data) {
|
||||
base::threading::ScopedLock scopedLock(m_fileLocksMapLock);
|
||||
std::string filename = data->logMessage()->logger()->typedConfigurations()->filename(data->logMessage()->level());
|
||||
auto lock = m_fileLocks.find(filename);
|
||||
if (lock == m_fileLocks.end()) {
|
||||
m_fileLocks.emplace(std::make_pair(filename, std::unique_ptr<base::threading::Mutex>(new base::threading::Mutex)));
|
||||
}
|
||||
}
|
||||
#else
|
||||
void LogDispatchCallback::handle(const LogDispatchData* /*data*/) {}
|
||||
#endif
|
||||
|
||||
base::threading::Mutex& LogDispatchCallback::fileHandle(const LogDispatchData* data) {
|
||||
auto it = m_fileLocks.find(data->logMessage()->logger()->typedConfigurations()->filename(data->logMessage()->level()));
|
||||
return *(it->second.get());
|
||||
}
|
||||
|
||||
namespace base {
|
||||
// DefaultLogDispatchCallback
|
||||
|
||||
void DefaultLogDispatchCallback::handle(const LogDispatchData* data) {
|
||||
#if defined(ELPP_THREAD_SAFE)
|
||||
LogDispatchCallback::handle(data);
|
||||
base::threading::ScopedLock scopedLock(fileHandle(data));
|
||||
#endif
|
||||
m_data = data;
|
||||
dispatch(m_data->logMessage()->logger()->logBuilder()->build(m_data->logMessage(),
|
||||
m_data->dispatchAction() == base::DispatchAction::NormalLog));
|
||||
@ -2348,6 +2459,8 @@ base::type::string_t DefaultLogBuilder::build(const LogMessage* logMessage, bool
|
||||
base::utils::Str::replaceFirstWithEscape(logLine, base::consts::kMessageFormatSpecifier, logMessage->message());
|
||||
}
|
||||
#if !defined(ELPP_DISABLE_CUSTOM_FORMAT_SPECIFIERS)
|
||||
el::base::threading::ScopedLock lock_(ELPP->customFormatSpecifiersLock());
|
||||
ELPP_UNUSED(lock_);
|
||||
for (std::vector<CustomFormatSpecifier>::const_iterator it = ELPP->customFormatSpecifiers()->begin();
|
||||
it != ELPP->customFormatSpecifiers()->end(); ++it) {
|
||||
std::string fs(it->formatSpecifier());
|
||||
@ -2368,10 +2481,15 @@ void LogDispatcher::dispatch(void) {
|
||||
if (!m_proceed) {
|
||||
return;
|
||||
}
|
||||
#ifndef ELPP_NO_GLOBAL_LOCK
|
||||
// see https://github.com/muflihun/easyloggingpp/issues/580
|
||||
// global lock is turned on by default unless
|
||||
// ELPP_NO_GLOBAL_LOCK is defined
|
||||
base::threading::ScopedLock scopedLock(ELPP->lock());
|
||||
base::TypedConfigurations* tc = m_logMessage.logger()->m_typedConfigurations;
|
||||
#endif
|
||||
base::TypedConfigurations* tc = m_logMessage->logger()->m_typedConfigurations;
|
||||
if (ELPP->hasFlag(LoggingFlag::StrictLogFileSizeCheck)) {
|
||||
tc->validateFileRolling(m_logMessage.level(), ELPP->preRollOutCallback());
|
||||
tc->validateFileRolling(m_logMessage->level(), ELPP->preRollOutCallback());
|
||||
}
|
||||
LogDispatchCallback* callback = nullptr;
|
||||
LogDispatchData data;
|
||||
@ -2379,7 +2497,7 @@ void LogDispatcher::dispatch(void) {
|
||||
: ELPP->m_logDispatchCallbacks) {
|
||||
callback = h.second.get();
|
||||
if (callback != nullptr && callback->enabled()) {
|
||||
data.setLogMessage(&m_logMessage);
|
||||
data.setLogMessage(m_logMessage);
|
||||
data.setDispatchAction(m_dispatchAction);
|
||||
callback->handle(&data);
|
||||
}
|
||||
@ -2390,7 +2508,7 @@ void LogDispatcher::dispatch(void) {
|
||||
|
||||
void MessageBuilder::initialize(Logger* logger) {
|
||||
m_logger = logger;
|
||||
m_containerLogSeperator = ELPP->hasFlag(LoggingFlag::NewLineForContainer) ?
|
||||
m_containerLogSeparator = ELPP->hasFlag(LoggingFlag::NewLineForContainer) ?
|
||||
ELPP_LITERAL("\n ") : ELPP_LITERAL(", ");
|
||||
}
|
||||
|
||||
@ -2426,6 +2544,7 @@ Writer& Writer::construct(int count, const char* loggerIds, ...) {
|
||||
va_list loggersList;
|
||||
va_start(loggersList, loggerIds);
|
||||
const char* id = loggerIds;
|
||||
m_loggerIds.reserve(count);
|
||||
for (int i = 0; i < count; ++i) {
|
||||
m_loggerIds.push_back(std::string(id));
|
||||
id = va_arg(loggersList, const char*);
|
||||
@ -2444,12 +2563,12 @@ void Writer::initializeLogger(const std::string& loggerId, bool lookup, bool nee
|
||||
m_logger = ELPP->registeredLoggers()->get(loggerId, ELPP->hasFlag(LoggingFlag::CreateLoggerAutomatically));
|
||||
}
|
||||
if (m_logger == nullptr) {
|
||||
ELPP->acquireLock();
|
||||
if (!ELPP->registeredLoggers()->has(std::string(base::consts::kDefaultLoggerId))) {
|
||||
// Somehow default logger has been unregistered. Not good! Register again
|
||||
ELPP->registeredLoggers()->get(std::string(base::consts::kDefaultLoggerId));
|
||||
{
|
||||
if (!ELPP->registeredLoggers()->has(std::string(base::consts::kDefaultLoggerId))) {
|
||||
// Somehow default logger has been unregistered. Not good! Register again
|
||||
ELPP->registeredLoggers()->get(std::string(base::consts::kDefaultLoggerId));
|
||||
}
|
||||
}
|
||||
ELPP->releaseLock(); // Need to unlock it for next writer
|
||||
Writer(Level::Debug, m_file, m_line, m_func).construct(1, base::consts::kDefaultLoggerId)
|
||||
<< "Logger [" << loggerId << "] is not registered yet!";
|
||||
m_proceed = false;
|
||||
@ -2509,25 +2628,35 @@ void Writer::processDispatch() {
|
||||
}
|
||||
|
||||
void Writer::triggerDispatch(void) {
|
||||
if (m_proceed) {
|
||||
base::LogDispatcher(m_proceed, LogMessage(m_level, m_file, m_line, m_func, m_verboseLevel,
|
||||
m_logger), m_dispatchAction).dispatch();
|
||||
}
|
||||
if (m_logger != nullptr) {
|
||||
m_logger->stream().str(ELPP_LITERAL(""));
|
||||
m_logger->releaseLock();
|
||||
}
|
||||
if (m_proceed && m_level == Level::Fatal
|
||||
&& !ELPP->hasFlag(LoggingFlag::DisableApplicationAbortOnFatalLog)) {
|
||||
base::Writer(Level::Warning, m_file, m_line, m_func).construct(1, base::consts::kDefaultLoggerId)
|
||||
<< "Aborting application. Reason: Fatal log at [" << m_file << ":" << m_line << "]";
|
||||
std::stringstream reasonStream;
|
||||
reasonStream << "Fatal log at [" << m_file << ":" << m_line << "]"
|
||||
<< " If you wish to disable 'abort on fatal log' please use "
|
||||
<< "el::Helpers::addFlag(el::LoggingFlag::DisableApplicationAbortOnFatalLog)";
|
||||
base::utils::abort(1, reasonStream.str());
|
||||
}
|
||||
m_proceed = false;
|
||||
try {
|
||||
if (m_proceed) {
|
||||
if (m_msg == nullptr) {
|
||||
LogMessage msg(m_level, m_file, m_line, m_func, m_verboseLevel,
|
||||
m_logger);
|
||||
base::LogDispatcher(m_proceed, &msg, m_dispatchAction).dispatch();
|
||||
} else {
|
||||
base::LogDispatcher(m_proceed, m_msg, m_dispatchAction).dispatch();
|
||||
}
|
||||
}
|
||||
if (m_logger != nullptr) {
|
||||
m_logger->stream().str(ELPP_LITERAL(""));
|
||||
m_logger->releaseLock();
|
||||
}
|
||||
if (m_proceed && m_level == Level::Fatal
|
||||
&& !ELPP->hasFlag(LoggingFlag::DisableApplicationAbortOnFatalLog)) {
|
||||
base::Writer(Level::Warning, m_file, m_line, m_func).construct(1, base::consts::kDefaultLoggerId)
|
||||
<< "Aborting application. Reason: Fatal log at [" << m_file << ":" << m_line << "]";
|
||||
std::stringstream reasonStream;
|
||||
reasonStream << "Fatal log at [" << m_file << ":" << m_line << "]"
|
||||
<< " If you wish to disable 'abort on fatal log' please use "
|
||||
<< "el::Loggers::addFlag(el::LoggingFlag::DisableApplicationAbortOnFatalLog)";
|
||||
base::utils::abort(1, reasonStream.str());
|
||||
}
|
||||
m_proceed = false;
|
||||
}
|
||||
catch(std::exception & ex){
|
||||
// Extremely low memory situation; don't let exception be unhandled.
|
||||
}
|
||||
}
|
||||
|
||||
// PErrorWriter
|
||||
@ -2556,7 +2685,7 @@ PerformanceTracker::PerformanceTracker(const std::string& blockName,
|
||||
m_level(level), m_hasChecked(false), m_lastCheckpointId(std::string()), m_enabled(false) {
|
||||
#if !defined(ELPP_DISABLE_PERFORMANCE_TRACKING) && ELPP_LOGGING_ENABLED
|
||||
// We store it locally so that if user happen to change configuration by the end of scope
|
||||
// or before calling checkpoint, we still depend on state of configuraton at time of construction
|
||||
// or before calling checkpoint, we still depend on state of configuration at time of construction
|
||||
el::Logger* loggerPtr = ELPP->registeredLoggers()->get(loggerId, false);
|
||||
m_enabled = loggerPtr != nullptr && loggerPtr->m_typedConfigurations->performanceTracking(m_level);
|
||||
if (m_enabled) {
|
||||
@ -2640,18 +2769,19 @@ namespace debug {
|
||||
|
||||
// StackTrace
|
||||
|
||||
StackTrace::StackTraceEntry::StackTraceEntry(std::size_t index, const char* loc, const char* demang, const char* hex,
|
||||
const char* addr) {
|
||||
m_index = index;
|
||||
m_location = std::string(loc);
|
||||
m_demangled = std::string(demang);
|
||||
m_hex = std::string(hex);
|
||||
m_addr = std::string(addr);
|
||||
StackTrace::StackTraceEntry::StackTraceEntry(std::size_t index, const std::string& loc, const std::string& demang,
|
||||
const std::string& hex,
|
||||
const std::string& addr) :
|
||||
m_index(index),
|
||||
m_location(loc),
|
||||
m_demangled(demang),
|
||||
m_hex(hex),
|
||||
m_addr(addr) {
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& ss, const StackTrace::StackTraceEntry& si) {
|
||||
ss << "[" << si.m_index << "] " << si.m_location << (si.m_demangled.empty() ? "" : ":") << si.m_demangled
|
||||
<< (si.m_hex.empty() ? "" : "+") << si.m_hex << si.m_addr;
|
||||
ss << "[" << si.m_index << "] " << si.m_location << (si.m_hex.empty() ? "" : "+") << si.m_hex << " " << si.m_addr <<
|
||||
(si.m_demangled.empty() ? "" : ":") << si.m_demangled;
|
||||
return ss;
|
||||
}
|
||||
|
||||
@ -2664,51 +2794,47 @@ std::ostream& operator<<(std::ostream& os, const StackTrace& st) {
|
||||
}
|
||||
|
||||
void StackTrace::generateNew(void) {
|
||||
#if ELPP_STACKTRACE
|
||||
#ifdef HAVE_EXECINFO
|
||||
m_stack.clear();
|
||||
void* stack[kMaxStack];
|
||||
unsigned int size = backtrace(stack, kMaxStack);
|
||||
char** strings = backtrace_symbols(stack, size);
|
||||
if (size > kStackStart) { // Skip StackTrace c'tor and generateNew
|
||||
for (std::size_t i = kStackStart; i < size; ++i) {
|
||||
char* mangName = nullptr;
|
||||
char* hex = nullptr;
|
||||
char* addr = nullptr;
|
||||
for (char* c = strings[i]; *c; ++c) {
|
||||
switch (*c) {
|
||||
case '(':
|
||||
mangName = c;
|
||||
break;
|
||||
case '+':
|
||||
hex = c;
|
||||
break;
|
||||
case ')':
|
||||
addr = c;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
std::string mangName;
|
||||
std::string location;
|
||||
std::string hex;
|
||||
std::string addr;
|
||||
|
||||
// entry: 2 crash.cpp.bin 0x0000000101552be5 _ZN2el4base5debug10StackTraceC1Ev + 21
|
||||
const std::string line(strings[i]);
|
||||
auto p = line.find("_");
|
||||
if (p != std::string::npos) {
|
||||
mangName = line.substr(p);
|
||||
mangName = mangName.substr(0, mangName.find(" +"));
|
||||
}
|
||||
p = line.find("0x");
|
||||
if (p != std::string::npos) {
|
||||
addr = line.substr(p);
|
||||
addr = addr.substr(0, addr.find("_"));
|
||||
}
|
||||
// Perform demangling if parsed properly
|
||||
if (mangName != nullptr && hex != nullptr && addr != nullptr && mangName < hex) {
|
||||
*mangName++ = '\0';
|
||||
*hex++ = '\0';
|
||||
*addr++ = '\0';
|
||||
if (!mangName.empty()) {
|
||||
int status = 0;
|
||||
char* demangName = abi::__cxa_demangle(mangName, 0, 0, &status);
|
||||
char* demangName = abi::__cxa_demangle(mangName.data(), 0, 0, &status);
|
||||
// if demangling is successful, output the demangled function name
|
||||
if (status == 0) {
|
||||
// Success (see http://gcc.gnu.org/onlinedocs/libstdc++/libstdc++-html-USERS-4.3/a01696.html)
|
||||
StackTraceEntry entry(i - 1, strings[i], demangName, hex, addr);
|
||||
StackTraceEntry entry(i - 1, location, demangName, hex, addr);
|
||||
m_stack.push_back(entry);
|
||||
} else {
|
||||
// Not successful - we will use mangled name
|
||||
StackTraceEntry entry(i - 1, strings[i], mangName, hex, addr);
|
||||
StackTraceEntry entry(i - 1, location, mangName, hex, addr);
|
||||
m_stack.push_back(entry);
|
||||
}
|
||||
free(demangName);
|
||||
} else {
|
||||
StackTraceEntry entry(i - 1, strings[i]);
|
||||
StackTraceEntry entry(i - 1, line);
|
||||
m_stack.push_back(entry);
|
||||
}
|
||||
}
|
||||
@ -2742,6 +2868,9 @@ static std::string crashReason(int sig) {
|
||||
}
|
||||
/// @brief Logs reason of crash from sig
|
||||
static void logCrashReason(int sig, bool stackTraceIfAvailable, Level level, const char* logger) {
|
||||
if (sig == SIGINT && ELPP->hasFlag(el::LoggingFlag::IgnoreSigInt)) {
|
||||
return;
|
||||
}
|
||||
std::stringstream ss;
|
||||
ss << "CRASH HANDLED; ";
|
||||
ss << crashReason(sig);
|
||||
@ -2820,7 +2949,6 @@ void Helpers::logCrashReason(int sig, bool stackTraceIfAvailable, Level level, c
|
||||
// Loggers
|
||||
|
||||
Logger* Loggers::getLogger(const std::string& identity, bool registerIfNotAvailable) {
|
||||
base::threading::ScopedLock scopedLock(ELPP->lock());
|
||||
return ELPP->registeredLoggers()->get(identity, registerIfNotAvailable);
|
||||
}
|
||||
|
||||
@ -2829,12 +2957,10 @@ void Loggers::setDefaultLogBuilder(el::LogBuilderPtr& logBuilderPtr) {
|
||||
}
|
||||
|
||||
bool Loggers::unregisterLogger(const std::string& identity) {
|
||||
base::threading::ScopedLock scopedLock(ELPP->lock());
|
||||
return ELPP->registeredLoggers()->remove(identity);
|
||||
}
|
||||
|
||||
bool Loggers::hasLogger(const std::string& identity) {
|
||||
base::threading::ScopedLock scopedLock(ELPP->lock());
|
||||
return ELPP->registeredLoggers()->has(identity);
|
||||
}
|
||||
|
||||
@ -2887,7 +3013,7 @@ const Configurations* Loggers::defaultConfigurations(void) {
|
||||
return ELPP->registeredLoggers()->defaultConfigurations();
|
||||
}
|
||||
|
||||
const base::LogStreamsReferenceMap* Loggers::logStreamsReference(void) {
|
||||
const base::LogStreamsReferenceMapPtr Loggers::logStreamsReference(void) {
|
||||
return ELPP->registeredLoggers()->logStreamsReference();
|
||||
}
|
||||
|
||||
@ -2984,11 +3110,11 @@ void Loggers::clearVModules(void) {
|
||||
// VersionInfo
|
||||
|
||||
const std::string VersionInfo::version(void) {
|
||||
return std::string("9.95.0");
|
||||
return std::string("9.96.7");
|
||||
}
|
||||
/// @brief Release date of current version
|
||||
const std::string VersionInfo::releaseDate(void) {
|
||||
return std::string("02-08-2017 2312hrs");
|
||||
return std::string("24-11-2018 0728hrs");
|
||||
}
|
||||
|
||||
} // namespace el
|
||||
|
@ -1,18 +1,19 @@
|
||||
//
|
||||
// Bismillah ar-Rahmaan ar-Raheem
|
||||
//
|
||||
// Easylogging++ v9.95.0
|
||||
// Easylogging++ v9.96.7
|
||||
// Single-header only, cross-platform logging library for C++ applications
|
||||
//
|
||||
// Copyright (c) 2017 muflihun.com
|
||||
// Copyright (c) 2012-2018 Amrayn Web Services
|
||||
// Copyright (c) 2012-2018 @abumusamq
|
||||
//
|
||||
// This library is released under the MIT Licence.
|
||||
// http://labs.muflihun.com/easyloggingpp/licence.php
|
||||
// https://github.com/amrayn/easyloggingpp/blob/master/LICENSE
|
||||
//
|
||||
// https://github.com/muflihun/easyloggingpp
|
||||
// https://muflihun.github.io/easyloggingpp
|
||||
// https://amrayn.com
|
||||
// http://muflihun.com
|
||||
//
|
||||
|
||||
#ifndef EASYLOGGINGPP_H
|
||||
#define EASYLOGGINGPP_H
|
||||
// Compilers and C++0x/C++11 Evaluation
|
||||
@ -93,7 +94,7 @@
|
||||
#else
|
||||
# define ELPP_OS_MAC 0
|
||||
#endif
|
||||
#if (defined(__FreeBSD__))
|
||||
#if (defined(__FreeBSD__) || defined(__FreeBSD_kernel__))
|
||||
# define ELPP_OS_FREEBSD 1
|
||||
#else
|
||||
# define ELPP_OS_FREEBSD 0
|
||||
@ -103,13 +104,28 @@
|
||||
#else
|
||||
# define ELPP_OS_SOLARIS 0
|
||||
#endif
|
||||
#if (defined(_AIX))
|
||||
# define ELPP_OS_AIX 1
|
||||
#else
|
||||
# define ELPP_OS_AIX 0
|
||||
#endif
|
||||
#if (defined(__NetBSD__))
|
||||
# define ELPP_OS_NETBSD 1
|
||||
#else
|
||||
# define ELPP_OS_NETBSD 0
|
||||
#endif
|
||||
#if defined(__EMSCRIPTEN__)
|
||||
# define ELPP_OS_EMSCRIPTEN 1
|
||||
#else
|
||||
# define ELPP_OS_EMSCRIPTEN 0
|
||||
#endif
|
||||
#if (defined(__QNX__) || defined(__QNXNTO__))
|
||||
# define ELPP_OS_QNX 1
|
||||
#else
|
||||
# define ELPP_OS_QNX 0
|
||||
#endif
|
||||
// Unix
|
||||
#if ((ELPP_OS_LINUX || ELPP_OS_MAC || ELPP_OS_FREEBSD || ELPP_OS_NETBSD || ELPP_OS_SOLARIS) && (!ELPP_OS_WINDOWS))
|
||||
#if ((ELPP_OS_LINUX || ELPP_OS_MAC || ELPP_OS_FREEBSD || ELPP_OS_NETBSD || ELPP_OS_SOLARIS || ELPP_OS_AIX || ELPP_OS_EMSCRIPTEN || ELPP_OS_QNX) && (!ELPP_OS_WINDOWS))
|
||||
# define ELPP_OS_UNIX 1
|
||||
#else
|
||||
# define ELPP_OS_UNIX 0
|
||||
@ -194,7 +210,7 @@ ELPP_INTERNAL_DEBUGGING_OUT_INFO << ELPP_INTERNAL_DEBUGGING_MSG(internalInfoStre
|
||||
# define ELPP_INTERNAL_INFO(lvl, msg)
|
||||
#endif // (defined(ELPP_DEBUG_INFO))
|
||||
#if (defined(ELPP_FEATURE_ALL)) || (defined(ELPP_FEATURE_CRASH_LOG))
|
||||
# if (ELPP_COMPILER_GCC && !ELPP_MINGW && !ELPP_OS_ANDROID)
|
||||
# if (ELPP_COMPILER_GCC && !ELPP_MINGW && !ELPP_CYGWIN && !ELPP_OS_ANDROID && !ELPP_OS_EMSCRIPTEN && !ELPP_OS_QNX)
|
||||
# define ELPP_STACKTRACE 1
|
||||
# else
|
||||
# if ELPP_COMPILER_MSVC
|
||||
@ -349,10 +365,10 @@ ELPP_INTERNAL_DEBUGGING_OUT_INFO << ELPP_INTERNAL_DEBUGGING_MSG(internalInfoStre
|
||||
# include <codecvt>
|
||||
# endif // ELPP_OS_WINDOWS
|
||||
#endif // defined(ELPP_UNICODE)
|
||||
#if ELPP_STACKTRACE
|
||||
#ifdef HAVE_EXECINFO
|
||||
# include <cxxabi.h>
|
||||
# include <execinfo.h>
|
||||
#endif // ELPP_STACKTRACE
|
||||
#endif // ENABLE_EXECINFO
|
||||
#if ELPP_OS_ANDROID
|
||||
# include <sys/system_properties.h>
|
||||
#endif // ELPP_OS_ANDROID
|
||||
@ -373,6 +389,7 @@ ELPP_INTERNAL_DEBUGGING_OUT_INFO << ELPP_INTERNAL_DEBUGGING_MSG(internalInfoStre
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <unordered_map>
|
||||
#include <utility>
|
||||
#include <functional>
|
||||
#include <algorithm>
|
||||
@ -410,9 +427,6 @@ ELPP_INTERNAL_DEBUGGING_OUT_INFO << ELPP_INTERNAL_DEBUGGING_MSG(internalInfoStre
|
||||
# if defined(ELPP_LOG_STD_ARRAY)
|
||||
# include <array>
|
||||
# endif // defined(ELPP_LOG_STD_ARRAY)
|
||||
# if defined(ELPP_LOG_UNORDERED_MAP)
|
||||
# include <unordered_map>
|
||||
# endif // defined(ELPP_LOG_UNORDERED_MAP)
|
||||
# if defined(ELPP_LOG_UNORDERED_SET)
|
||||
# include <unordered_set>
|
||||
# endif // defined(ELPP_UNORDERED_SET)
|
||||
@ -571,7 +585,7 @@ enum class Level : base::type::EnumType {
|
||||
Fatal = 8,
|
||||
/// @brief Information representing errors in application but application will keep running
|
||||
Error = 16,
|
||||
/// @brief Useful when application has potentially harmful situtaions
|
||||
/// @brief Useful when application has potentially harmful situations
|
||||
Warning = 32,
|
||||
/// @brief Information that can be highly useful and vary with verbose logging level.
|
||||
Verbose = 64,
|
||||
@ -580,6 +594,16 @@ enum class Level : base::type::EnumType {
|
||||
/// @brief Represents unknown level
|
||||
Unknown = 1010
|
||||
};
|
||||
} // namespace el
|
||||
namespace std {
|
||||
template<> struct hash<el::Level> {
|
||||
public:
|
||||
std::size_t operator()(const el::Level& l) const {
|
||||
return hash<el::base::type::EnumType> {}(static_cast<el::base::type::EnumType>(l));
|
||||
}
|
||||
};
|
||||
}
|
||||
namespace el {
|
||||
/// @brief Static class that contains helper functions for el::Level
|
||||
class LevelHelper : base::StaticClass {
|
||||
public:
|
||||
@ -621,7 +645,7 @@ enum class ConfigurationType : base::type::EnumType {
|
||||
ToStandardOutput = 4,
|
||||
/// @brief Determines format of logging corresponding level and logger.
|
||||
Format = 8,
|
||||
/// @brief Determines log file (full path) to write logs to for correponding level and logger
|
||||
/// @brief Determines log file (full path) to write logs to for corresponding level and logger
|
||||
Filename = 16,
|
||||
/// @brief Specifies precision of the subsecond part. It should be within range (1-6).
|
||||
SubsecondPrecision = 32,
|
||||
@ -652,7 +676,7 @@ class ConfigurationTypeHelper : base::StaticClass {
|
||||
static base::type::EnumType castToInt(ConfigurationType configurationType) {
|
||||
return static_cast<base::type::EnumType>(configurationType);
|
||||
}
|
||||
/// @brief Casts int(ushort) to configurationt type, useful for iterating through enum.
|
||||
/// @brief Casts int(ushort) to configuration type, useful for iterating through enum.
|
||||
static ConfigurationType castFromInt(base::type::EnumType c) {
|
||||
return static_cast<ConfigurationType>(c);
|
||||
}
|
||||
@ -681,7 +705,7 @@ enum class LoggingFlag : base::type::EnumType {
|
||||
LogDetailedCrashReason = 4,
|
||||
/// @brief Allows to disable application abortion when logged using FATAL level
|
||||
DisableApplicationAbortOnFatalLog = 8,
|
||||
/// @brief Flushes log with every log-entry (performance sensative) - Disabled by default
|
||||
/// @brief Flushes log with every log-entry (performance sensitive) - Disabled by default
|
||||
ImmediateFlush = 16,
|
||||
/// @brief Enables strict file rolling
|
||||
StrictLogFileSizeCheck = 32,
|
||||
@ -702,115 +726,43 @@ enum class LoggingFlag : base::type::EnumType {
|
||||
/// @brief Adds spaces b/w logs that separated by left-shift operator
|
||||
AutoSpacing = 8192,
|
||||
/// @brief Preserves time format and does not convert it to sec, hour etc (performance tracking only)
|
||||
FixedTimeFormat = 16384
|
||||
FixedTimeFormat = 16384,
|
||||
// @brief Ignore SIGINT or crash
|
||||
IgnoreSigInt = 32768,
|
||||
};
|
||||
namespace base {
|
||||
/// @brief Namespace containing constants used internally.
|
||||
namespace consts {
|
||||
#if defined(__GNUC__) && !defined(__clang__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wunused-variable"
|
||||
#endif
|
||||
// Level log values - These are values that are replaced in place of %level format specifier
|
||||
// Extra spaces after format specifiers are only for readability purposes in log files
|
||||
static const base::type::char_t* kInfoLevelLogValue = ELPP_LITERAL("INFO");
|
||||
static const base::type::char_t* kDebugLevelLogValue = ELPP_LITERAL("DEBUG");
|
||||
static const base::type::char_t* kWarningLevelLogValue = ELPP_LITERAL("WARNING");
|
||||
static const base::type::char_t* kErrorLevelLogValue = ELPP_LITERAL("ERROR");
|
||||
static const base::type::char_t* kFatalLevelLogValue = ELPP_LITERAL("FATAL");
|
||||
static const base::type::char_t* kVerboseLevelLogValue =
|
||||
ELPP_LITERAL("VERBOSE"); // will become VERBOSE-x where x = verbose level
|
||||
static const base::type::char_t* kTraceLevelLogValue = ELPP_LITERAL("TRACE");
|
||||
static const base::type::char_t* kInfoLevelShortLogValue = ELPP_LITERAL("I");
|
||||
static const base::type::char_t* kDebugLevelShortLogValue = ELPP_LITERAL("D");
|
||||
static const base::type::char_t* kWarningLevelShortLogValue = ELPP_LITERAL("W");
|
||||
static const base::type::char_t* kErrorLevelShortLogValue = ELPP_LITERAL("E");
|
||||
static const base::type::char_t* kFatalLevelShortLogValue = ELPP_LITERAL("F");
|
||||
static const base::type::char_t* kVerboseLevelShortLogValue = ELPP_LITERAL("V");
|
||||
static const base::type::char_t* kTraceLevelShortLogValue = ELPP_LITERAL("T");
|
||||
// Format specifiers - These are used to define log format
|
||||
static const base::type::char_t* kAppNameFormatSpecifier = ELPP_LITERAL("%app");
|
||||
static const base::type::char_t* kLoggerIdFormatSpecifier = ELPP_LITERAL("%logger");
|
||||
static const base::type::char_t* kThreadIdFormatSpecifier = ELPP_LITERAL("%thread");
|
||||
static const base::type::char_t* kSeverityLevelFormatSpecifier = ELPP_LITERAL("%level");
|
||||
static const base::type::char_t* kSeverityLevelShortFormatSpecifier = ELPP_LITERAL("%levshort");
|
||||
static const base::type::char_t* kDateTimeFormatSpecifier = ELPP_LITERAL("%datetime");
|
||||
static const base::type::char_t* kLogFileFormatSpecifier = ELPP_LITERAL("%file");
|
||||
static const base::type::char_t* kLogFileBaseFormatSpecifier = ELPP_LITERAL("%fbase");
|
||||
static const base::type::char_t* kLogLineFormatSpecifier = ELPP_LITERAL("%line");
|
||||
static const base::type::char_t* kLogLocationFormatSpecifier = ELPP_LITERAL("%loc");
|
||||
static const base::type::char_t* kLogFunctionFormatSpecifier = ELPP_LITERAL("%func");
|
||||
static const base::type::char_t* kCurrentUserFormatSpecifier = ELPP_LITERAL("%user");
|
||||
static const base::type::char_t* kCurrentHostFormatSpecifier = ELPP_LITERAL("%host");
|
||||
static const base::type::char_t* kMessageFormatSpecifier = ELPP_LITERAL("%msg");
|
||||
static const base::type::char_t* kVerboseLevelFormatSpecifier = ELPP_LITERAL("%vlevel");
|
||||
static const char* kDateTimeFormatSpecifierForFilename = "%datetime";
|
||||
// Date/time
|
||||
static const char* kDays[7] = { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" };
|
||||
static const char* kDaysAbbrev[7] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };
|
||||
static const char* kMonths[12] = { "January", "February", "March", "Apri", "May", "June", "July", "August",
|
||||
"September", "October", "November", "December"
|
||||
};
|
||||
static const char* kMonthsAbbrev[12] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
|
||||
static const char* kDefaultDateTimeFormat = "%Y-%M-%d %H:%m:%s,%g";
|
||||
static const char* kDefaultDateTimeFormatInFilename = "%Y-%M-%d_%H-%m";
|
||||
static const int kYearBase = 1900;
|
||||
static const char* kAm = "AM";
|
||||
static const char* kPm = "PM";
|
||||
// Miscellaneous constants
|
||||
static const char kFormatSpecifierCharValue = 'v';
|
||||
static const char kFormatSpecifierChar = '%';
|
||||
static const unsigned int kMaxLogPerCounter = 100000;
|
||||
static const unsigned int kMaxLogPerContainer = 100;
|
||||
static const unsigned int kDefaultSubsecondPrecision = 3;
|
||||
|
||||
#ifdef ELPP_DEFAULT_LOGGER
|
||||
static const char* kDefaultLoggerId = ELPP_DEFAULT_LOGGER;
|
||||
#else
|
||||
static const char* kDefaultLoggerId = "default";
|
||||
#endif
|
||||
|
||||
#if defined(ELPP_FEATURE_ALL) || defined(ELPP_FEATURE_PERFORMANCE_TRACKING)
|
||||
#ifdef ELPP_DEFAULT_PERFORMANCE_LOGGER
|
||||
static const char* kPerformanceLoggerId = ELPP_DEFAULT_PERFORMANCE_LOGGER;
|
||||
#else
|
||||
static const char* kPerformanceLoggerId = "performance";
|
||||
#endif // ELPP_DEFAULT_PERFORMANCE_LOGGER
|
||||
#endif
|
||||
|
||||
#if defined(ELPP_SYSLOG)
|
||||
static const char* kSysLogLoggerId = "syslog";
|
||||
#endif // defined(ELPP_SYSLOG)
|
||||
static const char* kNullPointer = "nullptr";
|
||||
static const char kFormatSpecifierChar = '%';
|
||||
#if ELPP_VARIADIC_TEMPLATES_SUPPORTED
|
||||
static const char kFormatSpecifierCharValue = 'v';
|
||||
#endif // ELPP_VARIADIC_TEMPLATES_SUPPORTED
|
||||
static const unsigned int kMaxLogPerContainer = 100;
|
||||
static const unsigned int kMaxLogPerCounter = 100000;
|
||||
static const unsigned int kDefaultSubsecondPrecision = 3;
|
||||
static const base::type::VerboseLevel kMaxVerboseLevel = 9;
|
||||
static const char* kUnknownUser = "user";
|
||||
static const char* kUnknownHost = "unknown-host";
|
||||
#if defined(ELPP_DEFAULT_LOG_FILE)
|
||||
static const char* kDefaultLogFile = ELPP_DEFAULT_LOG_FILE;
|
||||
#else
|
||||
# if ELPP_OS_UNIX
|
||||
# if ELPP_OS_ANDROID
|
||||
static const char* kDefaultLogFile = "logs/myeasylog.log";
|
||||
# else
|
||||
static const char* kDefaultLogFile = "logs/myeasylog.log";
|
||||
# endif // ELPP_OS_ANDROID
|
||||
# elif ELPP_OS_WINDOWS
|
||||
static const char* kDefaultLogFile = "logs\\myeasylog.log";
|
||||
# endif // ELPP_OS_UNIX
|
||||
#endif // defined(ELPP_DEFAULT_LOG_FILE)
|
||||
#if !defined(ELPP_DISABLE_LOG_FILE_FROM_ARG)
|
||||
static const char* kDefaultLogFileParam = "--default-log-file";
|
||||
#endif // !defined(ELPP_DISABLE_LOG_FILE_FROM_ARG)
|
||||
#if defined(ELPP_LOGGING_FLAGS_FROM_ARG)
|
||||
static const char* kLoggingFlagsParam = "--logging-flags";
|
||||
#endif // defined(ELPP_LOGGING_FLAGS_FROM_ARG)
|
||||
|
||||
#if ELPP_OS_WINDOWS
|
||||
static const char* kFilePathSeperator = "\\";
|
||||
static const char* kFilePathSeparator = "\\";
|
||||
#else
|
||||
static const char* kFilePathSeperator = "/";
|
||||
static const char* kFilePathSeparator = "/";
|
||||
#endif // ELPP_OS_WINDOWS
|
||||
static const char* kValidLoggerIdSymbols =
|
||||
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._";
|
||||
static const char* kConfigurationComment = "##";
|
||||
static const char* kConfigurationLevel = "*";
|
||||
static const char* kConfigurationLoggerId = "--";
|
||||
|
||||
static const std::size_t kSourceFilenameMaxLength = 100;
|
||||
static const std::size_t kSourceLineMaxLength = 10;
|
||||
static const Level kPerformanceTrackerDefaultLevel = Level::Info;
|
||||
@ -839,7 +791,7 @@ const struct {
|
||||
},
|
||||
{
|
||||
SIGFPE, "SIGFPE", "Erroneous arithmetic operation",
|
||||
"Arithemetic operation issue such as division by zero or operation resulting in overflow."
|
||||
"Arithmetic operation issue such as division by zero or operation resulting in overflow."
|
||||
},
|
||||
{
|
||||
SIGILL, "SIGILL", "Illegal instruction",
|
||||
@ -855,9 +807,6 @@ const struct {
|
||||
},
|
||||
};
|
||||
static const int kCrashSignalsCount = sizeof(kCrashSignals) / sizeof(kCrashSignals[0]);
|
||||
#if defined(__GNUC__) && !defined(__clang__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
} // namespace consts
|
||||
} // namespace base
|
||||
typedef std::function<void(const char*, std::size_t)> PreRollOutCallback;
|
||||
@ -1108,14 +1057,14 @@ class File : base::StaticClass {
|
||||
static bool createPath(const std::string& path);
|
||||
/// @brief Extracts path of filename with leading slash
|
||||
static std::string extractPathFromFilename(const std::string& fullPath,
|
||||
const char* seperator = base::consts::kFilePathSeperator);
|
||||
const char* separator = base::consts::kFilePathSeparator);
|
||||
/// @brief builds stripped filename and puts it in buff
|
||||
static void buildStrippedFilename(const char* filename, char buff[],
|
||||
std::size_t limit = base::consts::kSourceFilenameMaxLength);
|
||||
/// @brief builds base filename and puts it in buff
|
||||
static void buildBaseFilename(const std::string& fullPath, char buff[],
|
||||
std::size_t limit = base::consts::kSourceFilenameMaxLength,
|
||||
const char* seperator = base::consts::kFilePathSeperator);
|
||||
const char* separator = base::consts::kFilePathSeparator);
|
||||
};
|
||||
/// @brief String utilities helper class used internally. You should not use it.
|
||||
class Str : base::StaticClass {
|
||||
@ -1184,7 +1133,7 @@ class Str : base::StaticClass {
|
||||
static char* addToBuff(const char* str, char* buf, const char* bufLim);
|
||||
static char* clearBuff(char buff[], std::size_t lim);
|
||||
|
||||
/// @brief Converst wchar* to char*
|
||||
/// @brief Converts wchar* to char*
|
||||
/// NOTE: Need to free return value after use!
|
||||
static char* wcharPtrToCharPtr(const wchar_t* line);
|
||||
};
|
||||
@ -1225,7 +1174,7 @@ class OS : base::StaticClass {
|
||||
|
||||
/// @brief Gets current host name or computer name.
|
||||
///
|
||||
/// @detail For android systems this is device name with its manufacturer and model seperated by hyphen
|
||||
/// @detail For android systems this is device name with its manufacturer and model separated by hyphen
|
||||
static std::string currentHost(void);
|
||||
/// @brief Whether or not terminal supports colors
|
||||
static bool termSupportsColor(void);
|
||||
@ -1235,7 +1184,7 @@ class DateTime : base::StaticClass {
|
||||
public:
|
||||
/// @brief Cross platform gettimeofday for Windows and unix platform. This can be used to determine current microsecond.
|
||||
///
|
||||
/// @detail For unix system it uses gettimeofday(timeval*, timezone*) and for Windows, a seperate implementation is provided
|
||||
/// @detail For unix system it uses gettimeofday(timeval*, timezone*) and for Windows, a separate implementation is provided
|
||||
/// @param [in,out] tv Pointer that gets updated
|
||||
static void gettimeofday(struct timeval* tv);
|
||||
|
||||
@ -1257,8 +1206,8 @@ class DateTime : base::StaticClass {
|
||||
base::TimestampUnit timestampUnit);
|
||||
|
||||
|
||||
private:
|
||||
static struct ::tm* buildTimeInfo(struct timeval* currTime, struct ::tm* timeInfo);
|
||||
private:
|
||||
static char* parseFormat(char* buf, std::size_t bufSz, const char* format, const struct tm* tInfo,
|
||||
std::size_t msec, const base::SubsecondPrecision* ssPrec);
|
||||
};
|
||||
@ -1281,7 +1230,7 @@ class CommandLineArgs {
|
||||
}
|
||||
/// @brief Sets arguments and parses them
|
||||
void setArgs(int argc, char** argv);
|
||||
/// @brief Returns true if arguments contain paramKey with a value (seperated by '=')
|
||||
/// @brief Returns true if arguments contain paramKey with a value (separated by '=')
|
||||
bool hasParamWithValue(const char* paramKey) const;
|
||||
/// @brief Returns value of arguments
|
||||
/// @see hasParamWithValue(const char*)
|
||||
@ -1297,7 +1246,7 @@ class CommandLineArgs {
|
||||
private:
|
||||
int m_argc;
|
||||
char** m_argv;
|
||||
std::map<std::string, std::string> m_paramsWithValue;
|
||||
std::unordered_map<std::string, std::string> m_paramsWithValue;
|
||||
std::vector<std::string> m_params;
|
||||
};
|
||||
/// @brief Abstract registry (aka repository) that provides basic interface for pointer repository specified by T_Ptr type.
|
||||
@ -1422,7 +1371,7 @@ class AbstractRegistry : public base::threading::ThreadSafe {
|
||||
/// of AbstractRegistry<T_Ptr, Container>. Any implementation of this class should be
|
||||
/// explicitly (by using lock functions)
|
||||
template <typename T_Ptr, typename T_Key = const char*>
|
||||
class Registry : public AbstractRegistry<T_Ptr, std::map<T_Key, T_Ptr*>> {
|
||||
class Registry : public AbstractRegistry<T_Ptr, std::unordered_map<T_Key, T_Ptr*>> {
|
||||
public:
|
||||
typedef typename Registry<T_Ptr, T_Key>::iterator iterator;
|
||||
typedef typename Registry<T_Ptr, T_Key>::const_iterator const_iterator;
|
||||
@ -1437,7 +1386,7 @@ class Registry : public AbstractRegistry<T_Ptr, std::map<T_Key, T_Ptr*>> {
|
||||
this->reinitDeepCopy(sr);
|
||||
}
|
||||
|
||||
/// @brief Assignment operator that unregisters all the existing registeries and deeply copies each of repo element
|
||||
/// @brief Assignment operator that unregisters all the existing registries and deeply copies each of repo element
|
||||
/// @see unregisterAll()
|
||||
/// @see deepCopy(const AbstractRegistry&)
|
||||
Registry& operator=(const Registry& sr) {
|
||||
@ -1486,7 +1435,7 @@ class Registry : public AbstractRegistry<T_Ptr, std::map<T_Key, T_Ptr*>> {
|
||||
}
|
||||
|
||||
private:
|
||||
virtual void deepCopy(const AbstractRegistry<T_Ptr, std::map<T_Key, T_Ptr*>>& sr) ELPP_FINAL {
|
||||
virtual void deepCopy(const AbstractRegistry<T_Ptr, std::unordered_map<T_Key, T_Ptr*>>& sr) ELPP_FINAL {
|
||||
for (const_iterator it = sr.cbegin(); it != sr.cend(); ++it) {
|
||||
registerNew(it->first, new T_Ptr(*it->second));
|
||||
}
|
||||
@ -1518,7 +1467,7 @@ class RegistryWithPred : public AbstractRegistry<T_Ptr, std::vector<T_Ptr*>> {
|
||||
this->reinitDeepCopy(sr);
|
||||
}
|
||||
|
||||
/// @brief Assignment operator that unregisters all the existing registeries and deeply copies each of repo element
|
||||
/// @brief Assignment operator that unregisters all the existing registries and deeply copies each of repo element
|
||||
/// @see unregisterAll()
|
||||
/// @see deepCopy(const AbstractRegistry&)
|
||||
RegistryWithPred& operator=(const RegistryWithPred& sr) {
|
||||
@ -1565,7 +1514,7 @@ class RegistryWithPred : public AbstractRegistry<T_Ptr, std::vector<T_Ptr*>> {
|
||||
this->list().push_back(ptr);
|
||||
}
|
||||
|
||||
/// @brief Gets pointer from repository with speicifed arguments. Arguments are passed to predicate
|
||||
/// @brief Gets pointer from repository with specified arguments. Arguments are passed to predicate
|
||||
/// in order to validate pointer.
|
||||
template <typename T, typename T2>
|
||||
T_Ptr* get(const T& arg1, const T2 arg2) {
|
||||
@ -1586,7 +1535,7 @@ class RegistryWithPred : public AbstractRegistry<T_Ptr, std::vector<T_Ptr*>> {
|
||||
class Utils {
|
||||
public:
|
||||
template <typename T, typename TPtr>
|
||||
static bool installCallback(const std::string& id, std::map<std::string, TPtr>* mapT) {
|
||||
static bool installCallback(const std::string& id, std::unordered_map<std::string, TPtr>* mapT) {
|
||||
if (mapT->find(id) == mapT->end()) {
|
||||
mapT->insert(std::make_pair(id, TPtr(new T())));
|
||||
return true;
|
||||
@ -1595,15 +1544,15 @@ class Utils {
|
||||
}
|
||||
|
||||
template <typename T, typename TPtr>
|
||||
static void uninstallCallback(const std::string& id, std::map<std::string, TPtr>* mapT) {
|
||||
static void uninstallCallback(const std::string& id, std::unordered_map<std::string, TPtr>* mapT) {
|
||||
if (mapT->find(id) != mapT->end()) {
|
||||
mapT->erase(id);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T, typename TPtr>
|
||||
static T* callback(const std::string& id, std::map<std::string, TPtr>* mapT) {
|
||||
typename std::map<std::string, TPtr>::iterator iter = mapT->find(id);
|
||||
static T* callback(const std::string& id, std::unordered_map<std::string, TPtr>* mapT) {
|
||||
typename std::unordered_map<std::string, TPtr>::iterator iter = mapT->find(id);
|
||||
if (iter != mapT->end()) {
|
||||
return static_cast<T*>(iter->second.get());
|
||||
}
|
||||
@ -1948,7 +1897,8 @@ class Configurations : public base::utils::RegistryWithPred<Configuration, Confi
|
||||
|
||||
namespace base {
|
||||
typedef std::shared_ptr<base::type::fstream_t> FileStreamPtr;
|
||||
typedef std::map<std::string, FileStreamPtr> LogStreamsReferenceMap;
|
||||
typedef std::unordered_map<std::string, FileStreamPtr> LogStreamsReferenceMap;
|
||||
typedef std::shared_ptr<base::LogStreamsReferenceMap> LogStreamsReferenceMapPtr;
|
||||
/// @brief Configurations with data types.
|
||||
///
|
||||
/// @detail el::Configurations have string based values. This is whats used internally in order to read correct configurations.
|
||||
@ -1960,7 +1910,7 @@ class TypedConfigurations : public base::threading::ThreadSafe {
|
||||
/// @brief Constructor to initialize (construct) the object off el::Configurations
|
||||
/// @param configurations Configurations pointer/reference to base this typed configurations off.
|
||||
/// @param logStreamsReference Use ELPP->registeredLoggers()->logStreamsReference()
|
||||
TypedConfigurations(Configurations* configurations, base::LogStreamsReferenceMap* logStreamsReference);
|
||||
TypedConfigurations(Configurations* configurations, LogStreamsReferenceMapPtr logStreamsReference);
|
||||
|
||||
TypedConfigurations(const TypedConfigurations& other);
|
||||
|
||||
@ -1985,17 +1935,17 @@ class TypedConfigurations : public base::threading::ThreadSafe {
|
||||
|
||||
private:
|
||||
Configurations* m_configurations;
|
||||
std::map<Level, bool> m_enabledMap;
|
||||
std::map<Level, bool> m_toFileMap;
|
||||
std::map<Level, std::string> m_filenameMap;
|
||||
std::map<Level, bool> m_toStandardOutputMap;
|
||||
std::map<Level, base::LogFormat> m_logFormatMap;
|
||||
std::map<Level, base::SubsecondPrecision> m_subsecondPrecisionMap;
|
||||
std::map<Level, bool> m_performanceTrackingMap;
|
||||
std::map<Level, base::FileStreamPtr> m_fileStreamMap;
|
||||
std::map<Level, std::size_t> m_maxLogFileSizeMap;
|
||||
std::map<Level, std::size_t> m_logFlushThresholdMap;
|
||||
base::LogStreamsReferenceMap* m_logStreamsReference;
|
||||
std::unordered_map<Level, bool> m_enabledMap;
|
||||
std::unordered_map<Level, bool> m_toFileMap;
|
||||
std::unordered_map<Level, std::string> m_filenameMap;
|
||||
std::unordered_map<Level, bool> m_toStandardOutputMap;
|
||||
std::unordered_map<Level, base::LogFormat> m_logFormatMap;
|
||||
std::unordered_map<Level, base::SubsecondPrecision> m_subsecondPrecisionMap;
|
||||
std::unordered_map<Level, bool> m_performanceTrackingMap;
|
||||
std::unordered_map<Level, base::FileStreamPtr> m_fileStreamMap;
|
||||
std::unordered_map<Level, std::size_t> m_maxLogFileSizeMap;
|
||||
std::unordered_map<Level, std::size_t> m_logFlushThresholdMap;
|
||||
LogStreamsReferenceMapPtr m_logStreamsReference = nullptr;
|
||||
|
||||
friend class el::Helpers;
|
||||
friend class el::base::MessageBuilder;
|
||||
@ -2004,21 +1954,21 @@ class TypedConfigurations : public base::threading::ThreadSafe {
|
||||
friend class el::base::LogDispatcher;
|
||||
|
||||
template <typename Conf_T>
|
||||
inline Conf_T getConfigByVal(Level level, const std::map<Level, Conf_T>* confMap, const char* confName) {
|
||||
inline Conf_T getConfigByVal(Level level, const std::unordered_map<Level, Conf_T>* confMap, const char* confName) {
|
||||
base::threading::ScopedLock scopedLock(lock());
|
||||
return unsafeGetConfigByVal(level, confMap, confName); // This is not unsafe anymore - mutex locked in scope
|
||||
}
|
||||
|
||||
template <typename Conf_T>
|
||||
inline Conf_T& getConfigByRef(Level level, std::map<Level, Conf_T>* confMap, const char* confName) {
|
||||
inline Conf_T& getConfigByRef(Level level, std::unordered_map<Level, Conf_T>* confMap, const char* confName) {
|
||||
base::threading::ScopedLock scopedLock(lock());
|
||||
return unsafeGetConfigByRef(level, confMap, confName); // This is not unsafe anymore - mutex locked in scope
|
||||
}
|
||||
|
||||
template <typename Conf_T>
|
||||
Conf_T unsafeGetConfigByVal(Level level, const std::map<Level, Conf_T>* confMap, const char* confName) {
|
||||
Conf_T unsafeGetConfigByVal(Level level, const std::unordered_map<Level, Conf_T>* confMap, const char* confName) {
|
||||
ELPP_UNUSED(confName);
|
||||
typename std::map<Level, Conf_T>::const_iterator it = confMap->find(level);
|
||||
typename std::unordered_map<Level, Conf_T>::const_iterator it = confMap->find(level);
|
||||
if (it == confMap->end()) {
|
||||
try {
|
||||
return confMap->at(Level::Global);
|
||||
@ -2033,9 +1983,9 @@ class TypedConfigurations : public base::threading::ThreadSafe {
|
||||
}
|
||||
|
||||
template <typename Conf_T>
|
||||
Conf_T& unsafeGetConfigByRef(Level level, std::map<Level, Conf_T>* confMap, const char* confName) {
|
||||
Conf_T& unsafeGetConfigByRef(Level level, std::unordered_map<Level, Conf_T>* confMap, const char* confName) {
|
||||
ELPP_UNUSED(confName);
|
||||
typename std::map<Level, Conf_T>::iterator it = confMap->find(level);
|
||||
typename std::unordered_map<Level, Conf_T>::iterator it = confMap->find(level);
|
||||
if (it == confMap->end()) {
|
||||
try {
|
||||
return confMap->at(Level::Global);
|
||||
@ -2049,14 +1999,15 @@ class TypedConfigurations : public base::threading::ThreadSafe {
|
||||
}
|
||||
|
||||
template <typename Conf_T>
|
||||
void setValue(Level level, const Conf_T& value, std::map<Level, Conf_T>* confMap, bool includeGlobalLevel = true) {
|
||||
void setValue(Level level, const Conf_T& value, std::unordered_map<Level, Conf_T>* confMap,
|
||||
bool includeGlobalLevel = true) {
|
||||
// If map is empty and we are allowed to add into generic level (Level::Global), do it!
|
||||
if (confMap->empty() && includeGlobalLevel) {
|
||||
confMap->insert(std::make_pair(Level::Global, value));
|
||||
return;
|
||||
}
|
||||
// If same value exist in generic level already, dont add it to explicit level
|
||||
typename std::map<Level, Conf_T>::iterator it = confMap->find(Level::Global);
|
||||
typename std::unordered_map<Level, Conf_T>::iterator it = confMap->find(Level::Global);
|
||||
if (it != confMap->end() && it->second == value) {
|
||||
return;
|
||||
}
|
||||
@ -2218,21 +2169,26 @@ class LogDispatchData {
|
||||
inline base::DispatchAction dispatchAction(void) const {
|
||||
return m_dispatchAction;
|
||||
}
|
||||
private:
|
||||
LogMessage* m_logMessage;
|
||||
base::DispatchAction m_dispatchAction;
|
||||
friend class base::LogDispatcher;
|
||||
|
||||
inline void setLogMessage(LogMessage* logMessage) {
|
||||
m_logMessage = logMessage;
|
||||
}
|
||||
inline void setDispatchAction(base::DispatchAction dispatchAction) {
|
||||
m_dispatchAction = dispatchAction;
|
||||
}
|
||||
private:
|
||||
LogMessage* m_logMessage;
|
||||
base::DispatchAction m_dispatchAction;
|
||||
friend class base::LogDispatcher;
|
||||
|
||||
};
|
||||
class LogDispatchCallback : public Callback<LogDispatchData> {
|
||||
protected:
|
||||
virtual void handle(const LogDispatchData* data);
|
||||
base::threading::Mutex& fileHandle(const LogDispatchData* data);
|
||||
private:
|
||||
friend class base::LogDispatcher;
|
||||
std::unordered_map<std::string, std::unique_ptr<base::threading::Mutex>> m_fileLocks;
|
||||
base::threading::Mutex m_fileLocksMapLock;
|
||||
};
|
||||
class PerformanceTrackingCallback : public Callback<PerformanceTrackingData> {
|
||||
private:
|
||||
@ -2257,11 +2213,11 @@ class LogBuilder : base::NoCopy {
|
||||
typedef std::shared_ptr<LogBuilder> LogBuilderPtr;
|
||||
/// @brief Represents a logger holding ID and configurations we need to write logs
|
||||
///
|
||||
/// @detail This class does not write logs itself instead its used by writer to read configuations from.
|
||||
/// @detail This class does not write logs itself instead its used by writer to read configurations from.
|
||||
class Logger : public base::threading::ThreadSafe, public Loggable {
|
||||
public:
|
||||
Logger(const std::string& id, base::LogStreamsReferenceMap* logStreamsReference);
|
||||
Logger(const std::string& id, const Configurations& configurations, base::LogStreamsReferenceMap* logStreamsReference);
|
||||
Logger(const std::string& id, base::LogStreamsReferenceMapPtr logStreamsReference);
|
||||
Logger(const std::string& id, const Configurations& configurations, base::LogStreamsReferenceMapPtr logStreamsReference);
|
||||
Logger(const Logger& logger);
|
||||
Logger& operator=(const Logger& logger);
|
||||
|
||||
@ -2350,8 +2306,8 @@ inline void FUNCTION_NAME(const T&);
|
||||
std::string m_parentApplicationName;
|
||||
bool m_isConfigured;
|
||||
Configurations m_configurations;
|
||||
std::map<Level, unsigned int> m_unflushedCount;
|
||||
base::LogStreamsReferenceMap* m_logStreamsReference;
|
||||
std::unordered_map<Level, unsigned int> m_unflushedCount;
|
||||
base::LogStreamsReferenceMapPtr m_logStreamsReference = nullptr;
|
||||
LogBuilderPtr m_logBuilder;
|
||||
|
||||
friend class el::LogMessage;
|
||||
@ -2438,8 +2394,8 @@ class RegisteredLoggers : public base::utils::Registry<Logger, std::string> {
|
||||
base::utils::Registry<Logger, std::string>::unregister(logger->id());
|
||||
}
|
||||
|
||||
inline base::LogStreamsReferenceMap* logStreamsReference(void) {
|
||||
return &m_logStreamsReference;
|
||||
inline LogStreamsReferenceMapPtr logStreamsReference(void) {
|
||||
return m_logStreamsReference;
|
||||
}
|
||||
|
||||
inline void flushAll(void) {
|
||||
@ -2455,8 +2411,8 @@ class RegisteredLoggers : public base::utils::Registry<Logger, std::string> {
|
||||
private:
|
||||
LogBuilderPtr m_defaultLogBuilder;
|
||||
Configurations m_defaultConfigurations;
|
||||
base::LogStreamsReferenceMap m_logStreamsReference;
|
||||
std::map<std::string, base::type::LoggerRegistrationCallbackPtr> m_loggerRegistrationCallbacks;
|
||||
base::LogStreamsReferenceMapPtr m_logStreamsReference = nullptr;
|
||||
std::unordered_map<std::string, base::type::LoggerRegistrationCallbackPtr> m_loggerRegistrationCallbacks;
|
||||
friend class el::base::Storage;
|
||||
|
||||
void unsafeFlushAll(void);
|
||||
@ -2482,7 +2438,7 @@ class VRegistry : base::NoCopy, public base::threading::ThreadSafe {
|
||||
|
||||
bool allowed(base::type::VerboseLevel vlevel, const char* file);
|
||||
|
||||
inline const std::map<std::string, base::type::VerboseLevel>& modules(void) const {
|
||||
inline const std::unordered_map<std::string, base::type::VerboseLevel>& modules(void) const {
|
||||
return m_modules;
|
||||
}
|
||||
|
||||
@ -2496,7 +2452,7 @@ class VRegistry : base::NoCopy, public base::threading::ThreadSafe {
|
||||
private:
|
||||
base::type::VerboseLevel m_level;
|
||||
base::type::EnumType* m_pFlags;
|
||||
std::map<std::string, base::type::VerboseLevel> m_modules;
|
||||
std::unordered_map<std::string, base::type::VerboseLevel> m_modules;
|
||||
};
|
||||
} // namespace base
|
||||
class LogMessage {
|
||||
@ -2680,6 +2636,10 @@ class Storage : base::NoCopy, public base::threading::ThreadSafe {
|
||||
return &m_customFormatSpecifiers;
|
||||
}
|
||||
|
||||
base::threading::Mutex& customFormatSpecifiersLock() {
|
||||
return m_customFormatSpecifiersLock;
|
||||
}
|
||||
|
||||
inline void setLoggingLevel(Level level) {
|
||||
m_loggingLevel = level;
|
||||
}
|
||||
@ -2720,12 +2680,13 @@ class Storage : base::NoCopy, public base::threading::ThreadSafe {
|
||||
/// @brief Sets thread name for current thread. Requires std::thread
|
||||
inline void setThreadName(const std::string& name) {
|
||||
if (name.empty()) return;
|
||||
base::threading::ScopedLock scopedLock(lock());
|
||||
base::threading::ScopedLock scopedLock(m_threadNamesLock);
|
||||
m_threadNames[base::threading::getCurrentThreadId()] = name;
|
||||
}
|
||||
|
||||
inline std::string getThreadName(const std::string& threadId) {
|
||||
std::map<std::string, std::string>::const_iterator it = m_threadNames.find(threadId);
|
||||
base::threading::ScopedLock scopedLock(m_threadNamesLock);
|
||||
std::unordered_map<std::string, std::string>::const_iterator it = m_threadNames.find(threadId);
|
||||
if (it == m_threadNames.end()) {
|
||||
return threadId;
|
||||
}
|
||||
@ -2742,10 +2703,12 @@ class Storage : base::NoCopy, public base::threading::ThreadSafe {
|
||||
#endif // ELPP_ASYNC_LOGGING
|
||||
base::utils::CommandLineArgs m_commandLineArgs;
|
||||
PreRollOutCallback m_preRollOutCallback;
|
||||
std::map<std::string, base::type::LogDispatchCallbackPtr> m_logDispatchCallbacks;
|
||||
std::map<std::string, base::type::PerformanceTrackingCallbackPtr> m_performanceTrackingCallbacks;
|
||||
std::map<std::string, std::string> m_threadNames;
|
||||
std::unordered_map<std::string, base::type::LogDispatchCallbackPtr> m_logDispatchCallbacks;
|
||||
std::unordered_map<std::string, base::type::PerformanceTrackingCallbackPtr> m_performanceTrackingCallbacks;
|
||||
std::unordered_map<std::string, std::string> m_threadNames;
|
||||
std::vector<CustomFormatSpecifier> m_customFormatSpecifiers;
|
||||
base::threading::Mutex m_customFormatSpecifiersLock;
|
||||
base::threading::Mutex m_threadNamesLock;
|
||||
Level m_loggingLevel;
|
||||
|
||||
friend class el::Helpers;
|
||||
@ -2788,7 +2751,7 @@ class AsyncDispatchWorker : public base::IWorker, public base::threading::Thread
|
||||
void run(void);
|
||||
|
||||
void setContinueRunning(bool value) {
|
||||
base::threading::ScopedLock scopedLock(m_continueRunningMutex);
|
||||
base::threading::ScopedLock scopedLock(m_continueRunningLock);
|
||||
m_continueRunning = value;
|
||||
}
|
||||
|
||||
@ -2798,7 +2761,7 @@ class AsyncDispatchWorker : public base::IWorker, public base::threading::Thread
|
||||
private:
|
||||
std::condition_variable cv;
|
||||
bool m_continueRunning;
|
||||
base::threading::Mutex m_continueRunningMutex;
|
||||
base::threading::Mutex m_continueRunningLock;
|
||||
};
|
||||
#endif // ELPP_ASYNC_LOGGING
|
||||
} // namespace base
|
||||
@ -2810,9 +2773,9 @@ class DefaultLogBuilder : public LogBuilder {
|
||||
/// @brief Dispatches log messages
|
||||
class LogDispatcher : base::NoCopy {
|
||||
public:
|
||||
LogDispatcher(bool proceed, LogMessage&& logMessage, base::DispatchAction dispatchAction) :
|
||||
LogDispatcher(bool proceed, LogMessage* logMessage, base::DispatchAction dispatchAction) :
|
||||
m_proceed(proceed),
|
||||
m_logMessage(std::move(logMessage)),
|
||||
m_logMessage(logMessage),
|
||||
m_dispatchAction(std::move(dispatchAction)) {
|
||||
}
|
||||
|
||||
@ -2820,7 +2783,7 @@ class LogDispatcher : base::NoCopy {
|
||||
|
||||
private:
|
||||
bool m_proceed;
|
||||
LogMessage m_logMessage;
|
||||
LogMessage* m_logMessage;
|
||||
base::DispatchAction m_dispatchAction;
|
||||
};
|
||||
#if defined(ELPP_STL_LOGGING)
|
||||
@ -2902,7 +2865,7 @@ class IterableStack : public IterableContainer<T, Container>, public std::stack<
|
||||
// Log message builder
|
||||
class MessageBuilder {
|
||||
public:
|
||||
MessageBuilder(void) : m_logger(nullptr), m_containerLogSeperator(ELPP_LITERAL("")) {}
|
||||
MessageBuilder(void) : m_logger(nullptr), m_containerLogSeparator(ELPP_LITERAL("")) {}
|
||||
void initialize(Logger* logger);
|
||||
|
||||
# define ELPP_SIMPLE_LOG(LOG_TYPE)\
|
||||
@ -3090,7 +3053,7 @@ return writeIterator(template_inst.begin(), template_inst.end(), template_inst.s
|
||||
m_logger->stream() << ELPP_LITERAL(", ");
|
||||
operator << (static_cast<V>(map_.value(*begin)));
|
||||
m_logger->stream() << ELPP_LITERAL(")");
|
||||
m_logger->stream() << ((index_ < keys.size() -1) ? m_containerLogSeperator : ELPP_LITERAL(""));
|
||||
m_logger->stream() << ((index_ < keys.size() -1) ? m_containerLogSeparator : ELPP_LITERAL(""));
|
||||
}
|
||||
if (begin != end) {
|
||||
m_logger->stream() << ELPP_LITERAL("...");
|
||||
@ -3116,7 +3079,7 @@ return writeIterator(template_inst.begin(), template_inst.end(), template_inst.s
|
||||
m_logger->stream() << ELPP_LITERAL(", ");
|
||||
operator << (static_cast<V>(hash_.value(*begin)));
|
||||
m_logger->stream() << ELPP_LITERAL(")");
|
||||
m_logger->stream() << ((index_ < keys.size() -1) ? m_containerLogSeperator : ELPP_LITERAL(""));
|
||||
m_logger->stream() << ((index_ < keys.size() -1) ? m_containerLogSeparator : ELPP_LITERAL(""));
|
||||
}
|
||||
if (begin != end) {
|
||||
m_logger->stream() << ELPP_LITERAL("...");
|
||||
@ -3147,7 +3110,7 @@ return writeIterator(template_inst.begin(), template_inst.end(), template_inst.s
|
||||
/// have begin() and end() methods that return respective iterators
|
||||
/// @param ContainerType Type of container e.g, MyList from WX_DECLARE_LIST(int, MyList); in wxwidgets
|
||||
/// @param SizeMethod Method used to get size of container.
|
||||
/// @param ElementInstance Instance of element to be fed out. Insance name is "elem". See WXELPP_ENABLED macro
|
||||
/// @param ElementInstance Instance of element to be fed out. Instance name is "elem". See WXELPP_ENABLED macro
|
||||
/// for an example usage
|
||||
#define MAKE_CONTAINERELPP_FRIENDLY(ContainerType, SizeMethod, ElementInstance) \
|
||||
el::base::type::ostream_t& operator<<(el::base::type::ostream_t& ss, const ContainerType& container) {\
|
||||
@ -3189,14 +3152,14 @@ ELPP_LITERAL("(") << elem->first << ELPP_LITERAL(", ") << elem->second << ELPP_L
|
||||
#undef ELPP_ITERATOR_CONTAINER_LOG_FIVE_ARG
|
||||
private:
|
||||
Logger* m_logger;
|
||||
const base::type::char_t* m_containerLogSeperator;
|
||||
const base::type::char_t* m_containerLogSeparator;
|
||||
|
||||
template<class Iterator>
|
||||
MessageBuilder& writeIterator(Iterator begin_, Iterator end_, std::size_t size_) {
|
||||
m_logger->stream() << ELPP_LITERAL("[");
|
||||
for (std::size_t i = 0; begin_ != end_ && i < base::consts::kMaxLogPerContainer; ++i, ++begin_) {
|
||||
operator << (*begin_);
|
||||
m_logger->stream() << ((i < size_ - 1) ? m_containerLogSeperator : ELPP_LITERAL(""));
|
||||
m_logger->stream() << ((i < size_ - 1) ? m_containerLogSeparator : ELPP_LITERAL(""));
|
||||
}
|
||||
if (begin_ != end_) {
|
||||
m_logger->stream() << ELPP_LITERAL("...");
|
||||
@ -3233,10 +3196,15 @@ class Writer : base::NoCopy {
|
||||
Writer(Level level, const char* file, base::type::LineNumber line,
|
||||
const char* func, base::DispatchAction dispatchAction = base::DispatchAction::NormalLog,
|
||||
base::type::VerboseLevel verboseLevel = 0) :
|
||||
m_level(level), m_file(file), m_line(line), m_func(func), m_verboseLevel(verboseLevel),
|
||||
m_msg(nullptr), m_level(level), m_file(file), m_line(line), m_func(func), m_verboseLevel(verboseLevel),
|
||||
m_logger(nullptr), m_proceed(false), m_dispatchAction(dispatchAction) {
|
||||
}
|
||||
|
||||
Writer(LogMessage* msg, base::DispatchAction dispatchAction = base::DispatchAction::NormalLog) :
|
||||
m_msg(msg), m_level(msg != nullptr ? msg->level() : Level::Unknown),
|
||||
m_line(0), m_logger(nullptr), m_proceed(false), m_dispatchAction(dispatchAction) {
|
||||
}
|
||||
|
||||
virtual ~Writer(void) {
|
||||
processDispatch();
|
||||
}
|
||||
@ -3267,6 +3235,7 @@ class Writer : base::NoCopy {
|
||||
Writer& construct(Logger* logger, bool needLock = true);
|
||||
Writer& construct(int count, const char* loggerIds, ...);
|
||||
protected:
|
||||
LogMessage* m_msg;
|
||||
Level m_level;
|
||||
const char* m_file;
|
||||
const base::type::LineNumber m_line;
|
||||
@ -3325,6 +3294,7 @@ void Logger::log_(Level level, int vlevel, const T& log) {
|
||||
base::DispatchAction::NormalLog, vlevel).construct(this, false) << log;
|
||||
} else {
|
||||
stream().str(ELPP_LITERAL(""));
|
||||
releaseLock();
|
||||
}
|
||||
} else {
|
||||
base::Writer(level, "FILE", 0, "FUNCTION").construct(this, false) << log;
|
||||
@ -3332,23 +3302,23 @@ void Logger::log_(Level level, int vlevel, const T& log) {
|
||||
}
|
||||
template <typename T, typename... Args>
|
||||
inline void Logger::log(Level level, const char* s, const T& value, const Args&... args) {
|
||||
base::threading::ScopedLock scopedLock(lock());
|
||||
acquireLock(); // released in Writer!
|
||||
log_(level, 0, s, value, args...);
|
||||
}
|
||||
template <typename T>
|
||||
inline void Logger::log(Level level, const T& log) {
|
||||
base::threading::ScopedLock scopedLock(lock());
|
||||
acquireLock(); // released in Writer!
|
||||
log_(level, 0, log);
|
||||
}
|
||||
# if ELPP_VERBOSE_LOG
|
||||
template <typename T, typename... Args>
|
||||
inline void Logger::verbose(int vlevel, const char* s, const T& value, const Args&... args) {
|
||||
base::threading::ScopedLock scopedLock(lock());
|
||||
acquireLock(); // released in Writer!
|
||||
log_(el::Level::Verbose, vlevel, s, value, args...);
|
||||
}
|
||||
template <typename T>
|
||||
inline void Logger::verbose(int vlevel, const T& log) {
|
||||
base::threading::ScopedLock scopedLock(lock());
|
||||
acquireLock(); // released in Writer!
|
||||
log_(el::Level::Verbose, vlevel, log);
|
||||
}
|
||||
# else
|
||||
@ -3603,8 +3573,9 @@ class StackTrace : base::NoCopy {
|
||||
static const unsigned int kStackStart = 2; // We want to skip c'tor and StackTrace::generateNew()
|
||||
class StackTraceEntry {
|
||||
public:
|
||||
StackTraceEntry(std::size_t index, const char* loc, const char* demang, const char* hex, const char* addr);
|
||||
StackTraceEntry(std::size_t index, char* loc) :
|
||||
StackTraceEntry(std::size_t index, const std::string& loc, const std::string& demang, const std::string& hex,
|
||||
const std::string& addr);
|
||||
StackTraceEntry(std::size_t index, const std::string& loc) :
|
||||
m_index(index),
|
||||
m_location(loc) {
|
||||
}
|
||||
@ -3667,6 +3638,7 @@ class SysLogInitializer {
|
||||
public:
|
||||
SysLogInitializer(const char* processIdent, int options = 0, int facility = 0) {
|
||||
#if defined(ELPP_SYSLOG)
|
||||
(void)base::consts::kSysLogLoggerId;
|
||||
openlog(processIdent, options, facility);
|
||||
#else
|
||||
ELPP_UNUSED(processIdent);
|
||||
@ -3789,6 +3761,11 @@ class Helpers : base::StaticClass {
|
||||
static inline const el::base::utils::CommandLineArgs* commandLineArgs(void) {
|
||||
return ELPP->commandLineArgs();
|
||||
}
|
||||
/// @brief Reserve space for custom format specifiers for performance
|
||||
/// @see std::vector::reserve
|
||||
static inline void reserveCustomFormatSpecifiers(std::size_t size) {
|
||||
ELPP->m_customFormatSpecifiers.reserve(size);
|
||||
}
|
||||
/// @brief Installs user defined format specifier and handler
|
||||
static inline void installCustomFormatSpecifier(const CustomFormatSpecifier& customFormatSpecifier) {
|
||||
ELPP->installCustomFormatSpecifier(customFormatSpecifier);
|
||||
@ -3802,7 +3779,7 @@ class Helpers : base::StaticClass {
|
||||
return ELPP->hasCustomFormatSpecifier(formatSpecifier);
|
||||
}
|
||||
static inline void validateFileRolling(Logger* logger, Level level) {
|
||||
if (logger == nullptr) return;
|
||||
if (ELPP == nullptr || logger == nullptr) return;
|
||||
logger->m_typedConfigurations->validateFileRolling(level, ELPP->preRollOutCallback());
|
||||
}
|
||||
};
|
||||
@ -3854,7 +3831,7 @@ class Loggers : base::StaticClass {
|
||||
/// @brief Returns current default
|
||||
static const Configurations* defaultConfigurations(void);
|
||||
/// @brief Returns log stream reference pointer if needed by user
|
||||
static const base::LogStreamsReferenceMap* logStreamsReference(void);
|
||||
static const base::LogStreamsReferenceMapPtr logStreamsReference(void);
|
||||
/// @brief Default typed configuration based on existing defaultConf
|
||||
static base::TypedConfigurations defaultTypedConfigurations(void);
|
||||
/// @brief Populates all logger IDs in current repository.
|
||||
@ -3865,7 +3842,7 @@ class Loggers : base::StaticClass {
|
||||
/// @brief Configures loggers using command line arg. Ensure you have already set command line args,
|
||||
/// @return False if invalid argument or argument with no value provided, true if attempted to configure logger.
|
||||
/// If true is returned that does not mean it has been configured successfully, it only means that it
|
||||
/// has attempeted to configure logger using configuration file provided in argument
|
||||
/// has attempted to configure logger using configuration file provided in argument
|
||||
static bool configureFromArg(const char* argKey);
|
||||
/// @brief Flushes all loggers for all levels - Be careful if you dont know how many loggers are registered
|
||||
static void flushAll(void);
|
||||
|
@ -21,11 +21,14 @@ TEST(FileUtilsTest, GetSizeOfFile) {
|
||||
EXPECT_EQ(File::getSizeOfFile(fs), strlen(data));
|
||||
}
|
||||
|
||||
#if !ELPP_OS_EMSCRIPTEN
|
||||
// this doesn't work as expected under emscripten's filesystem emulation
|
||||
TEST(FileUtilsTest, PathExists) {
|
||||
EXPECT_TRUE(File::pathExists(filename));
|
||||
removeFile(filename);
|
||||
EXPECT_FALSE(File::pathExists(filename));
|
||||
}
|
||||
#endif
|
||||
|
||||
TEST(FileUtilsTest, ExtractPathFromFilename) {
|
||||
EXPECT_EQ("/this/is/path/on/unix/", File::extractPathFromFilename("/this/is/path/on/unix/file.txt"));
|
||||
@ -34,11 +37,17 @@ TEST(FileUtilsTest, ExtractPathFromFilename) {
|
||||
|
||||
TEST(FileUtilsTest, CreatePath) {
|
||||
const char* path = "/tmp/my/one/long/path";
|
||||
#if !ELPP_OS_EMSCRIPTEN
|
||||
// it'll be reported as existing in emscripten
|
||||
EXPECT_FALSE(File::pathExists(path));
|
||||
#endif
|
||||
EXPECT_TRUE(File::createPath(path));
|
||||
EXPECT_TRUE(File::pathExists(path));
|
||||
removeFile(path);
|
||||
|
||||
#if !ELPP_OS_EMSCRIPTEN
|
||||
EXPECT_FALSE(File::pathExists(path));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
@ -22,7 +22,7 @@ TEST(FormatSpecifierTest, TestLevShortSpecifier) {
|
||||
el::Helpers::setArgs(2, param);
|
||||
|
||||
|
||||
// Regression origional %level still correct
|
||||
// Regression original %level still correct
|
||||
Configurations c;
|
||||
c.setGlobally(el::ConfigurationType::Format, "%level %msg");
|
||||
c.set(el::Level::Verbose, el::ConfigurationType::Format, "%level-%vlevel %msg");
|
||||
|
@ -3,7 +3,8 @@
|
||||
|
||||
#include "test.h"
|
||||
|
||||
#if ELPP_OS_UNIX
|
||||
#if ELPP_OS_UNIX && !ELPP_OS_EMSCRIPTEN
|
||||
// this doesn't make any sense under emscripten; you can't shell out
|
||||
TEST(OSUtilsTest, GetBashOutput) {
|
||||
const char* bashCommand = "echo 'test'";
|
||||
std::string bashResult = OS::getBashOutput(bashCommand);
|
||||
|
@ -101,9 +101,17 @@ TEST(TypedConfigurationsTest, NonExistentFileCreation) {
|
||||
c.set(Level::Error, ConfigurationType::Filename, "/tmp/logs/el.gtest.log");
|
||||
TypedConfigurations tConf(&c, ELPP->registeredLoggers()->logStreamsReference());
|
||||
EXPECT_TRUE(tConf.toFile(Level::Global));
|
||||
EXPECT_FALSE(tConf.toFile(Level::Info));
|
||||
EXPECT_TRUE(tConf.toFile(Level::Error));
|
||||
|
||||
#if ELPP_OS_EMSCRIPTEN == 1
|
||||
// On Emscripten, all files can be created; we actually expect success here
|
||||
EXPECT_TRUE(tConf.toFile(Level::Info));
|
||||
EXPECT_NE(nullptr, tConf.fileStream(Level::Info)); // not nullptr (emulated fs)
|
||||
#else
|
||||
EXPECT_EQ(nullptr, tConf.fileStream(Level::Info)); // nullptr
|
||||
EXPECT_FALSE(tConf.toFile(Level::Info));
|
||||
#endif
|
||||
|
||||
EXPECT_TRUE(tConf.toFile(Level::Error));
|
||||
EXPECT_NE(nullptr, tConf.fileStream(Level::Error)); // Not null
|
||||
}
|
||||
|
||||
|
6
tools/cpplint.py
vendored
6
tools/cpplint.py
vendored
@ -113,7 +113,7 @@ Syntax: cpplint.py [--verbose=#] [--output=vs7] [--filter=-x,+y,...]
|
||||
ignored.
|
||||
|
||||
Examples:
|
||||
Assuing that src/.git exists, the header guard CPP variables for
|
||||
Assuming that src/.git exists, the header guard CPP variables for
|
||||
src/chrome/browser/ui/browser.h are:
|
||||
|
||||
No flag => CHROME_BROWSER_UI_BROWSER_H_
|
||||
@ -196,7 +196,7 @@ _ERROR_CATEGORIES = [
|
||||
'whitespace/todo'
|
||||
]
|
||||
|
||||
# The default state of the category filter. This is overrided by the --filter=
|
||||
# The default state of the category filter. This is overridden by the --filter=
|
||||
# flag. By default all errors are on, so only add here categories that should be
|
||||
# off by default (i.e., categories that must be enabled by the --filter= flags).
|
||||
# All entries here should start with a '-' or '+', as in the --filter= flag.
|
||||
@ -4076,7 +4076,7 @@ def CheckForNonConstReference(filename, clean_lines, linenum,
|
||||
# inside declarators: reference parameter
|
||||
# We will exclude the first two cases by checking that we are not inside a
|
||||
# function body, including one that was just introduced by a trailing '{'.
|
||||
# TODO(unknwon): Doesn't account for preprocessor directives.
|
||||
# TODO(unknown): Doesn't account for preprocessor directives.
|
||||
# TODO(unknown): Doesn't account for 'catch(Exception& e)' [rare].
|
||||
check_params = False
|
||||
if not nesting_state.stack:
|
||||
|
@ -1,8 +1,8 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Bash script that helps with releasing new versions of EasyLogging++
|
||||
# Revision: 1.4
|
||||
# @author mkhan3189
|
||||
# Bash script that helps with releasing new versions of Easylogging++
|
||||
# Revision: 1.5
|
||||
# author @abumusamq
|
||||
#
|
||||
# Usage:
|
||||
# ./release.sh [repo-root] [homepage-repo-root] [curr-version] [new-version] [do-not-ask]
|
||||
@ -69,11 +69,12 @@ if [ "$confirm" = "y" ]; then
|
||||
cp $1/src/easylogging++.h .
|
||||
cp $1/src/easylogging++.cc .
|
||||
cp $1/CHANGELOG.md CHANGELOG.txt
|
||||
cp $1/LICENCE LICENCE.txt
|
||||
zip easyloggingpp_v$NEW_VERSION.zip easylogging++.h easylogging++.cc LICENCE.txt CHANGELOG.txt
|
||||
tar -pczf easyloggingpp_v$NEW_VERSION.tar.gz easylogging++.h easylogging++.cc LICENCE.txt CHANGELOG.txt
|
||||
cp $1/README.md README.txt
|
||||
cp $1/LICENSE LICENSE.txt
|
||||
zip easyloggingpp_v$NEW_VERSION.zip easylogging++.h easylogging++.cc LICENSE.txt CHANGELOG.txt README.txt
|
||||
tar -pczf easyloggingpp_v$NEW_VERSION.tar.gz easylogging++.h easylogging++.cc LICENSE.txt CHANGELOG.txt README.txt
|
||||
mv easyloggingpp_v$NEW_VERSION.zip $2/
|
||||
mv easyloggingpp_v$NEW_VERSION.tar.gz $2/
|
||||
rm easylogging++.h easylogging++.cc CHANGELOG.txt LICENCE.txt
|
||||
rm easylogging++.h easylogging++.cc CHANGELOG.txt LICENSE.txt README.txt
|
||||
echo "\n---------- PLEASE CHANGE CMakeLists.txt MANUALLY ----------- \n"
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user