0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-12-01 09:32:32 +01:00

SERVER-14417 migrated QGLOG to query log component. removed verboseQueryLogging server parameter. retained qlogOn and qlogOff functions

This commit is contained in:
Benety Goh 2014-07-09 14:44:14 -04:00
parent 269682556e
commit 3716b4ab4b
2 changed files with 34 additions and 11 deletions

View File

@ -26,24 +26,40 @@
* it in the license file.
*/
#include "mongo/platform/basic.h"
#include "mongo/db/query/qlog.h"
#include "mongo/db/server_options.h"
#include "mongo/db/server_parameters.h"
#include "mongo/logger/logger.h"
namespace mongo {
MONGO_EXPORT_SERVER_PARAMETER(verboseQueryLogging, bool, false);
namespace {
/**
* Updates log severity of 'verboseQueryLogComponent' in global log domain.
*/
bool setVerboseQueryLogging(bool newValue) {
bool old = logger::globalLogDomain()->shouldLog(verboseQueryLogComponent,
verboseQueryLogSeverity);
if (newValue) {
logger::globalLogDomain()->setMinimumLoggedSeverity(verboseQueryLogComponent,
verboseQueryLogSeverity);
}
else {
logger::globalLogDomain()->clearMinimumLoggedSeverity(verboseQueryLogComponent);
}
return old;
}
} // namespace
bool qlogOff() {
bool old = verboseQueryLogging;
verboseQueryLogging = false;
return old;
return setVerboseQueryLogging(false);
}
bool qlogOn() {
bool old = verboseQueryLogging;
verboseQueryLogging = true;
return old;
return setVerboseQueryLogging(true);
}
} // namespace mongo

View File

@ -30,12 +30,19 @@
#include <ostream>
#include "mongo/util/log.h"
namespace mongo {
extern bool verboseQueryLogging;
/**
* Verbose query logging is determined by the 'Query' log level in the global log domain.
* Set to verbosity 5 to enable.
*/
const logger::LogComponent verboseQueryLogComponent = logger::LogComponent::kQuery;
const logger::LogSeverity verboseQueryLogSeverity = logger::LogSeverity::Debug(5);
// With a #define like this, we don't evaluate the costly toString()s that are QLOG'd
#define QLOG() if (verboseQueryLogging) log() << "[QLOG] "
#define QLOG() MONGO_LOG_COMPONENT(verboseQueryLogSeverity, verboseQueryLogComponent) << "[QLOG] "
bool qlogOff();
bool qlogOn();