Skip to content

Commit

Permalink
Merge pull request #438 from easylogging/develop
Browse files Browse the repository at this point in the history
v9.88 Release
  • Loading branch information
easylogging authored Dec 29, 2016
2 parents 6c76ca1 + ed2ddaa commit 1c42012
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 36 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
‫بسم الله الرَّحْمَنِ الرَّحِيمِ


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

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

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

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

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

Expand Down Expand Up @@ -93,7 +93,7 @@

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

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

Expand Down
21 changes: 21 additions & 0 deletions doc/RELEASE-NOTES-v9.88
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Easylogging++ v9.88 RELEASE NOTES
---------------------------------

Release type: Minor
API changes: No
Breaking Change: No

==========================
= INTERNAL =
==========================

- Some type refactors for better results
- Exposing some functions for external use

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

- See https://github.com/easylogging/easyloggingpp/blob/v9.88/README.md for manual for this release
- See https://github.com/easylogging/easyloggingpp/tree/master/doc for other release notes
- Closed issues: https://github.com/easylogging/easyloggingpp/issues?page=1&state=closed
80 changes: 48 additions & 32 deletions src/easylogging++.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//
// Bismillah ar-Rahmaan ar-Raheem
//
// Easylogging++ v9.87
// Easylogging++ v9.88
// Single-header only, cross-platform logging library for C++ applications
//
// Copyright (c) 2017 muflihun.com
Expand Down Expand Up @@ -498,8 +498,9 @@ typedef std::ostream ostream_t;
# define ELPP_COUT_LINE(logLine) logLine << std::flush
#endif // defined(ELPP_CUSTOM_COUT_LINE)
typedef unsigned short EnumType;
typedef unsigned short VerboseLevel;
typedef unsigned long int LineNumber;
typedef std::shared_ptr<base::Storage> StoragePointer;
typedef int VerboseLevel;
typedef std::shared_ptr<LogDispatchCallback> LogDispatchCallbackPtr;
typedef std::shared_ptr<PerformanceTrackingCallback> PerformanceTrackingCallbackPtr;
typedef std::unique_ptr<el::base::PerformanceTracker> PerformanceTrackerPtr;
Expand Down Expand Up @@ -1668,14 +1669,20 @@ class DateTime : base::StaticClass {
/// @param format User provided date/time format
/// @param msWidth A pointer to base::MillisecondsWidth from configuration (non-null)
/// @returns string based date time in specified format.
static inline std::string getDateTime(const char* format, const base::MillisecondsWidth* msWidth) {
static std::string getDateTime(const char* format, const base::MillisecondsWidth* msWidth) {
struct timeval currTime;
gettimeofday(&currTime);
return timevalToString(currTime, format, msWidth);
}

/// @brief Converts timeval (struct from ctime) to string using specified format and milliseconds width
static std::string timevalToString(struct timeval tval, const char* format,
const el::base::MillisecondsWidth* msWidth) {
struct ::tm timeInfo;
buildTimeInfo(&currTime, &timeInfo);
buildTimeInfo(&tval, &timeInfo);
const int kBuffSize = 30;
char buff_[kBuffSize] = "";
parseFormat(buff_, kBuffSize, format, &timeInfo, static_cast<std::size_t>(currTime.tv_usec / msWidth->m_offset),
parseFormat(buff_, kBuffSize, format, &timeInfo, static_cast<std::size_t>(tval.tv_usec / msWidth->m_offset),
msWidth);
return std::string(buff_);
}
Expand Down Expand Up @@ -1709,6 +1716,7 @@ class DateTime : base::StaticClass {
}
}


private:
static inline struct ::tm* buildTimeInfo(struct timeval* currTime, struct ::tm* timeInfo) {
#if ELPP_OS_UNIX
Expand Down Expand Up @@ -3284,7 +3292,7 @@ class HitCounter {
m_hitCounts(0) {
}

HitCounter(const char* filename, unsigned long int lineNumber) :
HitCounter(const char* filename, base::type::LineNumber lineNumber) :
m_filename(filename),
m_lineNumber(lineNumber),
m_hitCounts(0) {
Expand All @@ -3307,7 +3315,7 @@ class HitCounter {
}

/// @brief Resets location of current hit counter
inline void resetLocation(const char* filename, unsigned long int lineNumber) {
inline void resetLocation(const char* filename, base::type::LineNumber lineNumber) {
m_filename = filename;
m_lineNumber = lineNumber;
}
Expand All @@ -3324,7 +3332,7 @@ class HitCounter {
return m_filename;
}

inline unsigned long int lineNumber(void) const {
inline base::type::LineNumber lineNumber(void) const {
return m_lineNumber;
}

Expand All @@ -3338,7 +3346,7 @@ class HitCounter {

class Predicate {
public:
Predicate(const char* filename, unsigned long int lineNumber)
Predicate(const char* filename, base::type::LineNumber lineNumber)
: m_filename(filename),
m_lineNumber(lineNumber) {
}
Expand All @@ -3350,20 +3358,20 @@ class HitCounter {

private:
const char* m_filename;
unsigned long int m_lineNumber;
base::type::LineNumber m_lineNumber;
};

private:
const char* m_filename;
unsigned long int m_lineNumber;
base::type::LineNumber m_lineNumber;
std::size_t m_hitCounts;
};
/// @brief Repository for hit counters used across the application
class RegisteredHitCounters : public base::utils::RegistryWithPred<base::HitCounter, base::HitCounter::Predicate> {
public:
/// @brief Validates counter for every N, i.e, registers new if does not exist otherwise updates original one
/// @return True if validation resulted in triggering hit. Meaning logs should be written everytime true is returned
bool validateEveryN(const char* filename, unsigned long int lineNumber, std::size_t n) {
bool validateEveryN(const char* filename, base::type::LineNumber lineNumber, std::size_t n) {
base::threading::ScopedLock scopedLock(lock());
base::HitCounter* counter = get(filename, lineNumber);
if (counter == nullptr) {
Expand All @@ -3376,7 +3384,7 @@ class RegisteredHitCounters : public base::utils::RegistryWithPred<base::HitCoun

/// @brief Validates counter for hits >= N, i.e, registers new if does not exist otherwise updates original one
/// @return True if validation resulted in triggering hit. Meaning logs should be written everytime true is returned
bool validateAfterN(const char* filename, unsigned long int lineNumber, std::size_t n) {
bool validateAfterN(const char* filename, base::type::LineNumber lineNumber, std::size_t n) {
base::threading::ScopedLock scopedLock(lock());
base::HitCounter* counter = get(filename, lineNumber);
if (counter == nullptr) {
Expand All @@ -3393,7 +3401,7 @@ class RegisteredHitCounters : public base::utils::RegistryWithPred<base::HitCoun

/// @brief Validates counter for hits are <= n, i.e, registers new if does not exist otherwise updates original one
/// @return True if validation resulted in triggering hit. Meaning logs should be written everytime true is returned
bool validateNTimes(const char* filename, unsigned long int lineNumber, std::size_t n) {
bool validateNTimes(const char* filename, base::type::LineNumber lineNumber, std::size_t n) {
base::threading::ScopedLock scopedLock(lock());
base::HitCounter* counter = get(filename, lineNumber);
if (counter == nullptr) {
Expand All @@ -3407,7 +3415,7 @@ class RegisteredHitCounters : public base::utils::RegistryWithPred<base::HitCoun
}

/// @brief Gets hit counter registered at specified position
inline const base::HitCounter* getCounter(const char* filename, unsigned long int lineNumber) {
inline const base::HitCounter* getCounter(const char* filename, base::type::LineNumber lineNumber) {
base::threading::ScopedLock scopedLock(lock());
return get(filename, lineNumber);
}
Expand Down Expand Up @@ -3783,6 +3791,11 @@ class RegisteredLoggers : public base::utils::Registry<Logger, std::string> {
unsafeFlushAll();
}

inline void setDefaultLogBuilder(LogBuilderPtr& logBuilderPtr) {
base::threading::ScopedLock scopedLock(lock());
m_defaultLogBuilder = logBuilderPtr;
}

private:
LogBuilderPtr m_defaultLogBuilder;
Configurations m_defaultConfigurations;
Expand All @@ -3807,9 +3820,7 @@ class VRegistry : base::NoCopy, public base::threading::ThreadSafe {
/// @brief Sets verbose level. Accepted range is 0-9
inline void setLevel(base::type::VerboseLevel level) {
base::threading::ScopedLock scopedLock(lock());
if (level < 0)
m_level = 0;
else if (level > 9)
if (level > 9)
m_level = base::consts::kMaxVerboseLevel;
else
m_level = level;
Expand Down Expand Up @@ -3946,7 +3957,7 @@ class VRegistry : base::NoCopy, public base::threading::ThreadSafe {
} // namespace base
class LogMessage {
public:
LogMessage(Level level, const std::string& file, unsigned long int line, const std::string& func,
LogMessage(Level level, const std::string& file, base::type::LineNumber line, const std::string& func,
base::type::VerboseLevel verboseLevel, Logger* logger) :
m_level(level), m_file(file), m_line(line), m_func(func),
m_verboseLevel(verboseLevel), m_logger(logger), m_message(logger->stream().str()) {
Expand All @@ -3957,7 +3968,7 @@ class LogMessage {
inline const std::string& file(void) const {
return m_file;
}
inline unsigned long int line(void) const {
inline base::type::LineNumber line(void) const {
return m_line;
}
inline const std::string& func(void) const {
Expand All @@ -3975,7 +3986,7 @@ class LogMessage {
private:
Level m_level;
std::string m_file;
unsigned long int m_line;
base::type::LineNumber m_line;
std::string m_func;
base::type::VerboseLevel m_verboseLevel;
Logger* m_logger;
Expand Down Expand Up @@ -4104,15 +4115,15 @@ class Storage : base::NoCopy, public base::threading::ThreadSafe {
base::utils::safeDelete(m_vRegistry);
}

inline bool validateEveryNCounter(const char* filename, unsigned long int lineNumber, std::size_t occasion) {
inline bool validateEveryNCounter(const char* filename, base::type::LineNumber lineNumber, std::size_t occasion) {
return hitCounters()->validateEveryN(filename, lineNumber, occasion);
}

inline bool validateAfterNCounter(const char* filename, unsigned long int lineNumber, std::size_t n) {
inline bool validateAfterNCounter(const char* filename, base::type::LineNumber lineNumber, std::size_t n) {
return hitCounters()->validateAfterN(filename, lineNumber, n);
}

inline bool validateNTimesCounter(const char* filename, unsigned long int lineNumber, std::size_t n) {
inline bool validateNTimesCounter(const char* filename, base::type::LineNumber lineNumber, std::size_t n) {
return hitCounters()->validateNTimes(filename, lineNumber, n);
}

Expand Down Expand Up @@ -5058,7 +5069,7 @@ class NullWriter : base::NoCopy {
/// @brief Main entry point of each logging
class Writer : base::NoCopy {
public:
Writer(Level level, const char* file, unsigned long int line,
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),
Expand Down Expand Up @@ -5119,7 +5130,7 @@ class Writer : base::NoCopy {
protected:
Level m_level;
const char* m_file;
const unsigned long int m_line;
const base::type::LineNumber m_line;
const char* m_func;
base::type::VerboseLevel m_verboseLevel;
Logger* m_logger;
Expand Down Expand Up @@ -5222,7 +5233,7 @@ class Writer : base::NoCopy {
};
class PErrorWriter : public base::Writer {
public:
PErrorWriter(Level level, const char* file, unsigned long int line,
PErrorWriter(Level level, const char* file, base::type::LineNumber line,
const char* func, base::DispatchAction dispatchAction = base::DispatchAction::NormalLog,
base::type::VerboseLevel verboseLevel = 0) :
base::Writer(level, file, line, func, dispatchAction, verboseLevel) {
Expand Down Expand Up @@ -5420,7 +5431,7 @@ class PerformanceTrackingData {
inline const char* file(void) const {
return m_file;
}
inline unsigned long int line(void) const {
inline base::type::LineNumber line(void) const {
return m_line;
}
inline const char* func(void) const {
Expand All @@ -5437,7 +5448,7 @@ class PerformanceTrackingData {
bool m_firstCheckpoint;
std::string m_checkpointId;
const char* m_file;
unsigned long int m_line;
base::type::LineNumber m_line;
const char* m_func;
inline void init(base::PerformanceTracker* performanceTracker, bool firstCheckpoint = false) {
m_performanceTracker = performanceTracker;
Expand Down Expand Up @@ -5498,7 +5509,8 @@ class PerformanceTracker : public base::threading::ThreadSafe, public Loggable {
#endif // !defined(ELPP_DISABLE_PERFORMANCE_TRACKING)
}
/// @brief A checkpoint for current performanceTracker block.
void checkpoint(const std::string& id = std::string(), const char* file = __FILE__, unsigned long int line = __LINE__,
void checkpoint(const std::string& id = std::string(), const char* file = __FILE__,
base::type::LineNumber line = __LINE__,
const char* func = "") {
#if !defined(ELPP_DISABLE_PERFORMANCE_TRACKING) && ELPP_LOGGING_ENABLED
if (m_enabled) {
Expand Down Expand Up @@ -5977,6 +5989,10 @@ class Loggers : base::StaticClass {
base::threading::ScopedLock scopedLock(ELPP->lock());
return ELPP->registeredLoggers()->get(identity, registerIfNotAvailable);
}
/// @brief Changes default log builder for future loggers
static inline void setDefaultLogBuilder(el::LogBuilderPtr& logBuilderPtr) {
ELPP->registeredLoggers()->setDefaultLogBuilder(logBuilderPtr);
}
/// @brief Unregisters logger - use it only when you know what you are doing, you may unregister
/// loggers initialized / used by third-party libs.
static inline bool unregisterLogger(const std::string& identity) {
Expand Down Expand Up @@ -6185,11 +6201,11 @@ class VersionInfo : base::StaticClass {
public:
/// @brief Current version number
static inline const std::string version(void) {
return std::string("9.87");
return std::string("9.88");
}
/// @brief Release date of current version
static inline const std::string releaseDate(void) {
return std::string("28-12-2016 1819hrs");
return std::string("30-12-2016 0114hrs");
}
};
} // namespace el
Expand Down

0 comments on commit 1c42012

Please sign in to comment.