Skip to content

Commit 6efc491

Browse files
authored
Merge pull request #610 from muflihun/develop
v9.96.0
2 parents 5fd54a0 + ee37c5c commit 6efc491

8 files changed

+78
-34
lines changed

ACKNOWLEDGEMENTS.md

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Acknowledgements
2+
This file contains list of contributors and acknowledgement of their efforts in making this library better especially by making acceptable code changes.
3+
4+
If we have missed your name please feel free to add it with contribution link.
5+
6+
| **Github User** | **Contribution** |
7+
|--------------------------------------|----------------------------------|
8+
| [@aparajita](https://github.com/aparajita) | [Separated out .h and .cc file](https://github.com/muflihun/easyloggingpp/pulls?q=is%3Apr+author%3Aaparajita) |
9+
| [@adah1972](https://github.com/adah1972) | [A lot of contributions](https://github.com/muflihun/easyloggingpp/pulls?q=is%3Apr+author%3Aadah1972) |
10+
| [@miguelmartin75](https://github.com/miguelmartin75) | [Issue #11](https://github.com/muflihun/easyloggingpp/issues/11), [PR #16](https://github.com/muflihun/easyloggingpp/pull/16) |
11+
| [@moneromooo-monero](https://github.com/moneromooo-monero) | [A lot of contributions](https://github.com/muflihun/easyloggingpp/pulls?q=is%3Apr+author%3Amoneromooo-monero)|
12+
| [@MonsieurNicolas](https://github.com/MonsieurNicolas) | [PR #593](https://github.com/muflihun/easyloggingpp/pull/593) |
13+
| [@acowley](https://github.com/acowley) | [PR #593](https://github.com/muflihun/easyloggingpp/pull/577) |
14+
| [@rggjan](https://github.com/rggjan) | [PR 561](https://github.com/muflihun/easyloggingpp/pull/561) |

CHANGELOG.md

+14
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
# Change Log
22

3+
## [9.96.0] - 14-02-2018
4+
### Fixes
5+
- Potential deadlocks in extreme edge case #609
6+
- Respect `MaxLogFileSize` setting even when `ELPP_NO_DEFAULT_LOG_FILE` is set (@MonsieurNicolas)
7+
- Disable log file **initially** when using `ELPP_NO_LOG_TO_FILE`, to be consistent with documentation (@rggjan)
8+
9+
### Updates
10+
- `el::Storage` no longer contains locks as it should be
11+
- Reformatted both files with `astyle`
12+
- License text updated
13+
14+
### Added
15+
- Install a pkg-config `.pc` file (@acowley)
16+
317
## [9.95.4] - 10-02-2018
418
### Fixes
519
- Fix documentation (see PR#597)

CMakeLists.txt

+8-2
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,12 @@ option(build_static_lib "Build easyloggingpp as a static library" OFF)
2626
option(lib_utc_datetime "Build library with UTC date/time logging" OFF)
2727

2828
set(ELPP_MAJOR_VERSION "9")
29-
set(ELPP_MINOR_VERSION "95")
30-
set(ELPP_PATCH_VERSION "4")
29+
set(ELPP_MINOR_VERSION "96")
30+
set(ELPP_PATCH_VERSION "0")
3131
set(ELPP_VERSION_STRING "${ELPP_MAJOR_VERSION}.${ELPP_MINOR_VERSION}.${ELPP_PATCH_VERSION}")
3232

3333
set(ELPP_INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/include" CACHE PATH "The directory the headers are installed in")
34+
set(ELPP_PKGCONFIG_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/share/pkgconfig" CACHE PATH "Installation directory for pkgconfig (.pc) files")
3435

3536
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
3637

@@ -40,6 +41,11 @@ install(FILES
4041
DESTINATION "${ELPP_INCLUDE_INSTALL_DIR}"
4142
COMPONENT dev)
4243

44+
configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/easyloggingpp.pc.cmakein
45+
${CMAKE_CURRENT_BINARY_DIR}/easyloggingpp.pc @ONLY)
46+
47+
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/easyloggingpp.pc DESTINATION "${ELPP_PKGCONFIG_INSTALL_DIR}")
48+
4349
if (build_static_lib)
4450
if (lib_utc_datetime)
4551
add_definitions(-DELPP_UTC_DATETIME)

LICENSE

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
The MIT License (MIT)
22

33
Copyright (c) 2012-2018 Muflihun Labs
4+
Copyright (c) 2012-2018 @abumusamq
45

56
https://github.com/muflihun/
6-
https://muflihun.com
7-
https://muflihun.github.io
7+
https://muflihun.com/
8+
https://muflihun.github.io/
89

910
Permission is hereby granted, free of charge, to any person obtaining a copy of
1011
this software and associated documentation files (the "Software"), to deal in

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
![banner]
66

7-
> **Manual For v9.95.4**
7+
> **Manual For v9.96.0**
88
99
[![Build Status (Master)](https://img.shields.io/travis/muflihun/easyloggingpp/master.svg)](https://travis-ci.org/muflihun/easyloggingpp) [![Build Status (Develop)](https://img.shields.io/travis/muflihun/easyloggingpp/develop.svg)](https://travis-ci.org/muflihun/easyloggingpp) [![Version](https://img.shields.io/github/release/muflihun/easyloggingpp.svg)](https://github.com/muflihun/easyloggingpp/releases/latest)
1010

@@ -100,7 +100,7 @@
100100
# Overview
101101
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) (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.
102102

103-
This manual is for Easylogging++ v9.95.4. For other versions please refer to corresponding [release](https://github.com/muflihun/easyloggingpp/releases) on github.
103+
This manual is for Easylogging++ v9.96.0. For other versions please refer to corresponding [release](https://github.com/muflihun/easyloggingpp/releases) on github.
104104

105105
> You may also be interested in [Residue](https://github.com/muflihun/residue/) logging server.
106106

cmake/easyloggingpp.pc.cmakein

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Name: easyloggingpp
2+
Description: Feature-rich single header C++ logging library
3+
Version: @ELPP_VERSION_STRING@
4+
prefix=@CMAKE_INSTALL_PREFIX@
5+
includedir=@ELPP_INCLUDE_INSTALL_DIR@
6+
Cflags: -I${includedir}

src/easylogging++.cc

+16-22
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
//
22
// Bismillah ar-Rahmaan ar-Raheem
33
//
4-
// Easylogging++ v9.95.4
4+
// Easylogging++ v9.96.0
55
// Cross-platform logging library for C++ applications
66
//
77
// Copyright (c) 2012-2018 Muflihun Labs
8+
// Copyright (c) 2012-2018 @abumusamq
89
//
910
// This library is released under the MIT Licence.
10-
// http://labs.muflihun.com/easyloggingpp/licence.php
11+
// https://github.com/muflihun/easyloggingpp/blob/master/LICENSE
1112
//
1213
// https://github.com/muflihun/easyloggingpp
1314
// https://muflihun.github.io/easyloggingpp
@@ -1622,10 +1623,11 @@ void TypedConfigurations::build(Configurations* configurations) {
16221623
} else if (conf->configurationType() == ConfigurationType::PerformanceTracking) {
16231624
setValue(Level::Global, getBool(conf->value()), &m_performanceTrackingMap);
16241625
} else if (conf->configurationType() == ConfigurationType::MaxLogFileSize) {
1625-
setValue(conf->level(), static_cast<std::size_t>(getULong(conf->value())), &m_maxLogFileSizeMap);
1626-
#if !defined(ELPP_NO_DEFAULT_LOG_FILE)
1627-
withFileSizeLimit.push_back(conf);
1628-
#endif // !defined(ELPP_NO_DEFAULT_LOG_FILE)
1626+
auto v = getULong(conf->value());
1627+
setValue(conf->level(), static_cast<std::size_t>(v), &m_maxLogFileSizeMap);
1628+
if (v != 0) {
1629+
withFileSizeLimit.push_back(conf);
1630+
}
16291631
} else if (conf->configurationType() == ConfigurationType::LogFlushThreshold) {
16301632
setValue(conf->level(), static_cast<std::size_t>(getULong(conf->value())), &m_logFlushThresholdMap);
16311633
}
@@ -1699,12 +1701,6 @@ std::string TypedConfigurations::resolveFilename(const std::string& filename) {
16991701
}
17001702

17011703
void TypedConfigurations::insertFile(Level level, const std::string& fullFilename) {
1702-
#if defined(ELPP_NO_LOG_TO_FILE)
1703-
setValue(level, false, &m_toFileMap);
1704-
ELPP_UNUSED(fullFilename);
1705-
m_fileStreamMap.insert(std::make_pair(level, base::FileStreamPtr(nullptr)));
1706-
return;
1707-
#endif
17081704
std::string resolvedFilename = resolveFilename(fullFilename);
17091705
if (resolvedFilename.empty()) {
17101706
std::cerr << "Could not load empty file for logging, please re-check your configurations for level ["
@@ -1840,8 +1836,10 @@ bool RegisteredLoggers::remove(const std::string& id) {
18401836
if (id == base::consts::kDefaultLoggerId) {
18411837
return false;
18421838
}
1839+
// get has internal lock
18431840
Logger* logger = base::utils::Registry<Logger, std::string>::get(id);
18441841
if (logger != nullptr) {
1842+
// unregister has internal lock
18451843
unregister(logger);
18461844
}
18471845
return true;
@@ -2046,7 +2044,7 @@ Storage::~Storage(void) {
20462044
}
20472045

20482046
bool Storage::hasCustomFormatSpecifier(const char* formatSpecifier) {
2049-
base::threading::ScopedLock scopedLock(lock());
2047+
base::threading::ScopedLock scopedLock(customFormatSpecifiersLock());
20502048
return std::find(m_customFormatSpecifiers.begin(), m_customFormatSpecifiers.end(),
20512049
formatSpecifier) != m_customFormatSpecifiers.end();
20522050
}
@@ -2055,12 +2053,12 @@ void Storage::installCustomFormatSpecifier(const CustomFormatSpecifier& customFo
20552053
if (hasCustomFormatSpecifier(customFormatSpecifier.formatSpecifier())) {
20562054
return;
20572055
}
2058-
base::threading::ScopedLock scopedLock(lock());
2056+
base::threading::ScopedLock scopedLock(customFormatSpecifiersLock());
20592057
m_customFormatSpecifiers.push_back(customFormatSpecifier);
20602058
}
20612059

20622060
bool Storage::uninstallCustomFormatSpecifier(const char* formatSpecifier) {
2063-
base::threading::ScopedLock scopedLock(lock());
2061+
base::threading::ScopedLock scopedLock(customFormatSpecifiersLock());
20642062
std::vector<CustomFormatSpecifier>::iterator it = std::find(m_customFormatSpecifiers.begin(),
20652063
m_customFormatSpecifiers.end(), formatSpecifier);
20662064
if (it != m_customFormatSpecifiers.end() && strcmp(formatSpecifier, it->formatSpecifier()) == 0) {
@@ -2349,7 +2347,7 @@ base::type::string_t DefaultLogBuilder::build(const LogMessage* logMessage, bool
23492347
base::utils::Str::replaceFirstWithEscape(logLine, base::consts::kMessageFormatSpecifier, logMessage->message());
23502348
}
23512349
#if !defined(ELPP_DISABLE_CUSTOM_FORMAT_SPECIFIERS)
2352-
el::base::threading::ScopedLock lock_(ELPP->lock());
2350+
el::base::threading::ScopedLock lock_(ELPP->customFormatSpecifiersLock());
23532351
ELPP_UNUSED(lock_);
23542352
for (std::vector<CustomFormatSpecifier>::const_iterator it = ELPP->customFormatSpecifiers()->begin();
23552353
it != ELPP->customFormatSpecifiers()->end(); ++it) {
@@ -2448,7 +2446,6 @@ void Writer::initializeLogger(const std::string& loggerId, bool lookup, bool nee
24482446
}
24492447
if (m_logger == nullptr) {
24502448
{
2451-
base::threading::ScopedLock scopedLock(ELPP->lock());
24522449
if (!ELPP->registeredLoggers()->has(std::string(base::consts::kDefaultLoggerId))) {
24532450
// Somehow default logger has been unregistered. Not good! Register again
24542451
ELPP->registeredLoggers()->get(std::string(base::consts::kDefaultLoggerId));
@@ -2824,7 +2821,6 @@ void Helpers::logCrashReason(int sig, bool stackTraceIfAvailable, Level level, c
28242821
// Loggers
28252822

28262823
Logger* Loggers::getLogger(const std::string& identity, bool registerIfNotAvailable) {
2827-
base::threading::ScopedLock scopedLock(ELPP->lock());
28282824
return ELPP->registeredLoggers()->get(identity, registerIfNotAvailable);
28292825
}
28302826

@@ -2833,12 +2829,10 @@ void Loggers::setDefaultLogBuilder(el::LogBuilderPtr& logBuilderPtr) {
28332829
}
28342830

28352831
bool Loggers::unregisterLogger(const std::string& identity) {
2836-
base::threading::ScopedLock scopedLock(ELPP->lock());
28372832
return ELPP->registeredLoggers()->remove(identity);
28382833
}
28392834

28402835
bool Loggers::hasLogger(const std::string& identity) {
2841-
base::threading::ScopedLock scopedLock(ELPP->lock());
28422836
return ELPP->registeredLoggers()->has(identity);
28432837
}
28442838

@@ -2988,11 +2982,11 @@ void Loggers::clearVModules(void) {
29882982
// VersionInfo
29892983

29902984
const std::string VersionInfo::version(void) {
2991-
return std::string("9.95.4");
2985+
return std::string("9.96.0");
29922986
}
29932987
/// @brief Release date of current version
29942988
const std::string VersionInfo::releaseDate(void) {
2995-
return std::string("10-02-2018 1109hrs");
2989+
return std::string("14-02-2018 1629hrs");
29962990
}
29972991

29982992
} // namespace el

src/easylogging++.h

+15-6
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
//
22
// Bismillah ar-Rahmaan ar-Raheem
33
//
4-
// Easylogging++ v9.95.4
4+
// Easylogging++ v9.96.0
55
// Single-header only, cross-platform logging library for C++ applications
66
//
77
// Copyright (c) 2012-2018 Muflihun Labs
8+
// Copyright (c) 2012-2018 @abumusamq
89
//
910
// This library is released under the MIT Licence.
10-
// http://labs.muflihun.com/easyloggingpp/licence.php
11+
// https://github.com/muflihun/easyloggingpp/blob/master/LICENSE
1112
//
1213
// https://github.com/muflihun/easyloggingpp
1314
// https://muflihun.github.io/easyloggingpp
1415
// http://muflihun.com
1516
//
17+
1618
#ifndef EASYLOGGINGPP_H
1719
#define EASYLOGGINGPP_H
1820
// Compilers and C++0x/C++11 Evaluation
@@ -2601,7 +2603,7 @@ class IWorker {
26012603
};
26022604
#endif // ELPP_ASYNC_LOGGING
26032605
/// @brief Easylogging++ management storage
2604-
class Storage : base::NoCopy, public base::threading::ThreadSafe {
2606+
class Storage : base::NoCopy {
26052607
public:
26062608
#if ELPP_ASYNC_LOGGING
26072609
Storage(const LogBuilderPtr& defaultLogBuilder, base::IWorker* asyncDispatchWorker);
@@ -2685,6 +2687,10 @@ class Storage : base::NoCopy, public base::threading::ThreadSafe {
26852687
return &m_customFormatSpecifiers;
26862688
}
26872689

2690+
base::threading::Mutex& customFormatSpecifiersLock() {
2691+
return m_customFormatSpecifiersLock;
2692+
}
2693+
26882694
inline void setLoggingLevel(Level level) {
26892695
m_loggingLevel = level;
26902696
}
@@ -2725,11 +2731,12 @@ class Storage : base::NoCopy, public base::threading::ThreadSafe {
27252731
/// @brief Sets thread name for current thread. Requires std::thread
27262732
inline void setThreadName(const std::string& name) {
27272733
if (name.empty()) return;
2728-
base::threading::ScopedLock scopedLock(lock());
2734+
base::threading::ScopedLock scopedLock(m_threadNamesLock);
27292735
m_threadNames[base::threading::getCurrentThreadId()] = name;
27302736
}
27312737

27322738
inline std::string getThreadName(const std::string& threadId) {
2739+
base::threading::ScopedLock scopedLock(m_threadNamesLock);
27332740
std::map<std::string, std::string>::const_iterator it = m_threadNames.find(threadId);
27342741
if (it == m_threadNames.end()) {
27352742
return threadId;
@@ -2751,6 +2758,8 @@ class Storage : base::NoCopy, public base::threading::ThreadSafe {
27512758
std::map<std::string, base::type::PerformanceTrackingCallbackPtr> m_performanceTrackingCallbacks;
27522759
std::map<std::string, std::string> m_threadNames;
27532760
std::vector<CustomFormatSpecifier> m_customFormatSpecifiers;
2761+
base::threading::Mutex m_customFormatSpecifiersLock;
2762+
base::threading::Mutex m_threadNamesLock;
27542763
Level m_loggingLevel;
27552764

27562765
friend class el::Helpers;
@@ -2793,7 +2802,7 @@ class AsyncDispatchWorker : public base::IWorker, public base::threading::Thread
27932802
void run(void);
27942803

27952804
void setContinueRunning(bool value) {
2796-
base::threading::ScopedLock scopedLock(m_continueRunningMutex);
2805+
base::threading::ScopedLock scopedLock(m_continueRunningLock);
27972806
m_continueRunning = value;
27982807
}
27992808

@@ -2803,7 +2812,7 @@ class AsyncDispatchWorker : public base::IWorker, public base::threading::Thread
28032812
private:
28042813
std::condition_variable cv;
28052814
bool m_continueRunning;
2806-
base::threading::Mutex m_continueRunningMutex;
2815+
base::threading::Mutex m_continueRunningLock;
28072816
};
28082817
#endif // ELPP_ASYNC_LOGGING
28092818
} // namespace base

0 commit comments

Comments
 (0)