Skip to content

Commit

Permalink
closes abumq#238 closes abumq#219 ability to change verbose propertie…
Browse files Browse the repository at this point in the history
…s on the fly
  • Loading branch information
abumq committed Dec 31, 2014
1 parent a13d91d commit c9ef782
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 21 deletions.
6 changes: 2 additions & 4 deletions doc/RELEASE-NOTES-v9.78
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@ Easylogging++ v9.78 RELEASE NOTES
Release type: Minor
API changes: No

==========================
= BUG FIXES =
==========================

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

- Ability to add, clear verbose modules on the fly (issue #219)
- Ability to set verbose logging level on the fly (issue #238)
- Solaris support

==========================
Expand Down
55 changes: 38 additions & 17 deletions src/easylogging++.h
Original file line number Diff line number Diff line change
Expand Up @@ -711,8 +711,8 @@ enum class LoggingFlag : base::type::EnumType {
CreateLoggerAutomatically = 4096,
/// @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
/// @brief Preserves time format and does not convert it to sec, hour etc (performance tracking only)
FixedTimeFormat = 16384
};
namespace base {
/// @brief Namespace containing constants used internally.
Expand Down Expand Up @@ -2461,8 +2461,8 @@ class Configurations : public base::utils::RegistryWithPred<Configuration, Confi
/// @return True if successfully parsed, false otherwise. You may define '_ELPP_DEBUG_ASSERT_FAILURE' to make sure you
/// do not proceed without successful parse.
inline bool parseFromFile(const std::string& configurationFile, Configurations* base = nullptr) {
// We initial assertion with true because if we have assertion diabled, we want to pass this
// check and if assertion is enabled we will have values re-assigned any way.
// We initial assertion with true because if we have assertion diabled, 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)),
"Configuration file [" << configurationFile << "] does not exist!");
Expand Down Expand Up @@ -3798,14 +3798,17 @@ class VRegistry : base::NoCopy, public base::threading::ThreadSafe {
setLevel(atoi(commandLineArgs->getParamValue("--v")));
} else if (commandLineArgs->hasParamWithValue("--V")) {
setLevel(atoi(commandLineArgs->getParamValue("--V")));
} else if ((commandLineArgs->hasParamWithValue("-vmodule"))
&& (!base::utils::hasFlag(LoggingFlag::DisableVModules, *m_pFlags))) {
} else if ((commandLineArgs->hasParamWithValue("-vmodule")) && vModulesEnabled()) {
setModules(commandLineArgs->getParamValue("-vmodule"));
} else if (commandLineArgs->hasParamWithValue("-VMODULE")
&& (!base::utils::hasFlag(LoggingFlag::DisableVModules, *m_pFlags))) {
} else if (commandLineArgs->hasParamWithValue("-VMODULE") && vModulesEnabled()) {
setModules(commandLineArgs->getParamValue("-VMODULE"));
}
}

/// @brief Whether or not vModules enabled
inline bool vModulesEnabled(void) {
return !base::utils::hasFlag(LoggingFlag::DisableVModules, *m_pFlags);
}

private:
base::type::VerboseLevel m_level;
Expand Down Expand Up @@ -5370,16 +5373,16 @@ class PerformanceTracker : public base::threading::ThreadSafe, public Loggable {
friend class base::DefaultPerformanceTrackingCallback;

const inline base::type::string_t getFormattedTimeTaken() const {
return getFormattedTimeTaken(m_startTime);
return getFormattedTimeTaken(m_startTime);
}
const base::type::string_t getFormattedTimeTaken(struct timeval startTime) const {
if (ELPP->hasFlag(LoggingFlag::FixedTimeFormat)) {
base::type::stringstream_t ss;
ss << base::utils::DateTime::getTimeDifference(m_endTime,
if (ELPP->hasFlag(LoggingFlag::FixedTimeFormat)) {
base::type::stringstream_t ss;
ss << base::utils::DateTime::getTimeDifference(m_endTime,
startTime, m_timestampUnit) << " " << base::consts::kTimeFormats[static_cast<base::type::EnumType>(m_timestampUnit)].unit;
return ss.str();
}
return ss.str();
}
return base::utils::DateTime::formatTime(base::utils::DateTime::getTimeDifference(m_endTime,
startTime, m_timestampUnit), m_timestampUnit);
}
Expand Down Expand Up @@ -5950,12 +5953,30 @@ class Loggers : base::StaticClass {
static inline void setLoggingLevel(Level level) {
ELPP->setLoggingLevel(level);
}
/// @brief Sets verbose level on the fly
static inline void setVerboseLevel(base::type::VerboseLevel level) {
ELPP->vRegistry()->setLevel(level);
}
/// @brief Gets current verbose level
static inline base::type::VerboseLevel verboseLevel(void) {
return ELPP->vRegistry()->level();
}
/// @brief Sets vmodules as specified (on the fly)
static inline void setVerboseVModules(const char* modules) {
if (ELPP->vRegistry()->vModulesEnabled()) {
ELPP->vRegistry()->setModules(modules);
}
}
/// @brief Clears vmodules
static inline void clearVerboseVModules(void) {
ELPP->vRegistry()->clearModules();
}
};
class VersionInfo : base::StaticClass {
public:
/// @brief Current version number
/// @brief Current version number
static inline const std::string version(void) { return std::string("9.77"); }
/// @brief Release date of current version
/// @brief Release date of current version
static inline const std::string releaseDate(void) { return std::string("21-11-2014 0915hrs"); }
};
} // namespace el
Expand Down

0 comments on commit c9ef782

Please sign in to comment.