mirror of https://gitee.com/bigwinds/arangodb
more files using the Logger
This commit is contained in:
parent
ff21453255
commit
00a68113b5
|
@ -25,7 +25,7 @@
|
|||
|
||||
#include "Aql/QueryCache.h"
|
||||
#include "Basics/conversions.h"
|
||||
#include "Basics/logging.h"
|
||||
#include "Basics/Logger.h"
|
||||
#include "Basics/tri-strings.h"
|
||||
#include "Basics/Exceptions.h"
|
||||
#include "VocBase/collection.h"
|
||||
|
@ -38,9 +38,8 @@
|
|||
|
||||
#ifdef TRI_ENABLE_MAINTAINER_MODE
|
||||
|
||||
#define LOG_TRX(trx, level, format, ...) \
|
||||
LOG_TRACE("trx #%llu.%d (%s): " format, (unsigned long long)trx->_id, \
|
||||
(int)level, StatusTransaction(trx->_status), __VA_ARGS__)
|
||||
#define LOG_TRX(trx, level) \
|
||||
LOG(TRACE) << "trx #" << trx->_id << "." << level << " (" << StatusTransaction(trx->_status) << "): "
|
||||
|
||||
#else
|
||||
|
||||
|
@ -378,13 +377,11 @@ static int LockCollection(TRI_transaction_collection_t* trxCollection,
|
|||
|
||||
int res;
|
||||
if (type == TRI_TRANSACTION_READ) {
|
||||
LOG_TRX(trx, nestingLevel, "read-locking collection %llu",
|
||||
(unsigned long long)trxCollection->_cid);
|
||||
LOG_TRX(trx, nestingLevel) << "read-locking collection " << trxCollection->_cid;
|
||||
res = document->beginReadTimed(timeout,
|
||||
TRI_TRANSACTION_DEFAULT_SLEEP_DURATION * 3);
|
||||
} else {
|
||||
LOG_TRX(trx, nestingLevel, "write-locking collection %llu",
|
||||
(unsigned long long)trxCollection->_cid);
|
||||
LOG_TRX(trx, nestingLevel) << "write-locking collection " << trxCollection->_cid;
|
||||
res = document->beginWriteTimed(timeout,
|
||||
TRI_TRANSACTION_DEFAULT_SLEEP_DURATION * 3);
|
||||
}
|
||||
|
@ -440,20 +437,16 @@ static int UnlockCollection(TRI_transaction_collection_t* trxCollection,
|
|||
trxCollection->_lockType == TRI_TRANSACTION_READ) {
|
||||
// we should never try to write-unlock a collection that we have only
|
||||
// read-locked
|
||||
LOG_ERROR("logic error in UnlockCollection");
|
||||
LOG(ERROR) << "logic error in UnlockCollection";
|
||||
TRI_ASSERT(false);
|
||||
return TRI_ERROR_INTERNAL;
|
||||
}
|
||||
|
||||
if (trxCollection->_lockType == TRI_TRANSACTION_READ) {
|
||||
LOG_TRX(trxCollection->_transaction, nestingLevel,
|
||||
"read-unlocking collection %llu",
|
||||
(unsigned long long)trxCollection->_cid);
|
||||
LOG_TRX(trxCollection->_transaction, nestingLevel) << "read-unlocking collection " << trxCollection->_cid;
|
||||
document->endRead();
|
||||
} else {
|
||||
LOG_TRX(trxCollection->_transaction, nestingLevel,
|
||||
"write-unlocking collection %llu",
|
||||
(unsigned long long)trxCollection->_cid);
|
||||
LOG_TRX(trxCollection->_transaction, nestingLevel) << "write-unlocking collection " << trxCollection->_cid;
|
||||
document->endWrite();
|
||||
}
|
||||
|
||||
|
@ -485,8 +478,7 @@ static int UseCollections(TRI_transaction_t* trx, int nestingLevel) {
|
|||
!HasHint(trx, TRI_TRANSACTION_HINT_NO_USAGE_LOCK)) {
|
||||
// use and usage-lock
|
||||
TRI_vocbase_col_status_e status;
|
||||
LOG_TRX(trx, nestingLevel, "using collection %llu",
|
||||
(unsigned long long)trxCollection->_cid);
|
||||
LOG_TRX(trx, nestingLevel) << "using collection " << trxCollection->_cid;
|
||||
trxCollection->_collection = TRI_UseCollectionByIdVocBase(
|
||||
trx->_vocbase, trxCollection->_cid, status);
|
||||
} else {
|
||||
|
@ -616,8 +608,7 @@ static int ReleaseCollections(TRI_transaction_t* trx, int nestingLevel) {
|
|||
// the top level transaction releases all collections
|
||||
if (trxCollection->_collection != nullptr) {
|
||||
// unuse collection, remove usage-lock
|
||||
LOG_TRX(trx, nestingLevel, "unusing collection %llu",
|
||||
(unsigned long long)trxCollection->_cid);
|
||||
LOG_TRX(trx, nestingLevel) << "unusing collection " << trxCollection->_cid;
|
||||
|
||||
TRI_ReleaseCollectionVocBase(trx->_vocbase, trxCollection->_collection);
|
||||
trxCollection->_collection = nullptr;
|
||||
|
@ -660,8 +651,7 @@ static int WriteBeginMarker(TRI_transaction_t* trx) {
|
|||
}
|
||||
|
||||
if (res != TRI_ERROR_NO_ERROR) {
|
||||
LOG_WARNING("could not save transaction begin marker in log: %s",
|
||||
TRI_errno_string(res));
|
||||
LOG(WARNING) << "could not save transaction begin marker in log: " << TRI_errno_string(res);
|
||||
}
|
||||
|
||||
return res;
|
||||
|
@ -696,8 +686,7 @@ static int WriteAbortMarker(TRI_transaction_t* trx) {
|
|||
}
|
||||
|
||||
if (res != TRI_ERROR_NO_ERROR) {
|
||||
LOG_WARNING("could not save transaction abort marker in log: %s",
|
||||
TRI_errno_string(res));
|
||||
LOG(WARNING) << "could not save transaction abort marker in log: " << TRI_errno_string(res);
|
||||
}
|
||||
|
||||
return res;
|
||||
|
@ -728,8 +717,7 @@ static int WriteCommitMarker(TRI_transaction_t* trx) {
|
|||
}
|
||||
|
||||
if (res != TRI_ERROR_NO_ERROR) {
|
||||
LOG_WARNING("could not save transaction commit marker in log: %s",
|
||||
TRI_errno_string(res));
|
||||
LOG(WARNING) << "could not save transaction commit marker in log: " << TRI_errno_string(res);
|
||||
}
|
||||
|
||||
return res;
|
||||
|
@ -902,7 +890,7 @@ int TRI_AddCollectionTransaction(TRI_transaction_t* trx, TRI_voc_cid_t cid,
|
|||
TRI_transaction_type_e accessType,
|
||||
int nestingLevel, bool force,
|
||||
bool allowImplicitCollections) {
|
||||
LOG_TRX(trx, nestingLevel, "adding collection %llu", (unsigned long long)cid);
|
||||
LOG_TRX(trx, nestingLevel) << "adding collection " << cid;
|
||||
|
||||
// upgrade transaction type if required
|
||||
if (nestingLevel == 0) {
|
||||
|
@ -1038,7 +1026,7 @@ bool TRI_IsLockedCollectionTransaction(
|
|||
if (accessType == TRI_TRANSACTION_WRITE &&
|
||||
trxCollection->_accessType != TRI_TRANSACTION_WRITE) {
|
||||
// wrong lock type
|
||||
LOG_WARNING("logic error. checking wrong lock type");
|
||||
LOG(WARNING) << "logic error. checking wrong lock type";
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1277,8 +1265,7 @@ int TRI_AddOperationTransaction(TRI_transaction_t* trx,
|
|||
|
||||
int TRI_BeginTransaction(TRI_transaction_t* trx, TRI_transaction_hint_t hints,
|
||||
int nestingLevel) {
|
||||
LOG_TRX(trx, nestingLevel, "%s %s transaction", "beginning",
|
||||
(trx->_type == TRI_TRANSACTION_READ ? "read" : "write"));
|
||||
LOG_TRX(trx, nestingLevel) << "beginning " << (trx->_type == TRI_TRANSACTION_READ ? "read" : "write") << " transaction";
|
||||
|
||||
if (nestingLevel == 0) {
|
||||
TRI_ASSERT(trx->_status == TRI_TRANSACTION_CREATED);
|
||||
|
@ -1346,8 +1333,7 @@ int TRI_BeginTransaction(TRI_transaction_t* trx, TRI_transaction_hint_t hints,
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int TRI_CommitTransaction(TRI_transaction_t* trx, int nestingLevel) {
|
||||
LOG_TRX(trx, nestingLevel, "%s %s transaction", "committing",
|
||||
(trx->_type == TRI_TRANSACTION_READ ? "read" : "write"));
|
||||
LOG_TRX(trx, nestingLevel) << "committing " << (trx->_type == TRI_TRANSACTION_READ ? "read" : "write") << " transaction";
|
||||
|
||||
TRI_ASSERT(trx->_status == TRI_TRANSACTION_RUNNING);
|
||||
|
||||
|
@ -1384,8 +1370,7 @@ int TRI_CommitTransaction(TRI_transaction_t* trx, int nestingLevel) {
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int TRI_AbortTransaction(TRI_transaction_t* trx, int nestingLevel) {
|
||||
LOG_TRX(trx, nestingLevel, "%s %s transaction", "aborting",
|
||||
(trx->_type == TRI_TRANSACTION_READ ? "read" : "write"));
|
||||
LOG_TRX(trx, nestingLevel) << "aborting " << (trx->_type == TRI_TRANSACTION_READ ? "read" : "write") << " transaction";
|
||||
|
||||
TRI_ASSERT(trx->_status == TRI_TRANSACTION_RUNNING);
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
#include "ArangoClient.h"
|
||||
|
||||
#include "Basics/files.h"
|
||||
#include "Basics/logging.h"
|
||||
#include "Basics/Logger.h"
|
||||
#include "Basics/messages.h"
|
||||
#include "Basics/tri-strings.h"
|
||||
#include "Basics/terminal-utils.h"
|
||||
|
@ -304,7 +304,7 @@ void ArangoClient::parse(ProgramOptions& options,
|
|||
|
||||
if (!_configFile.empty()) {
|
||||
if (StringUtils::tolower(_configFile) == std::string("none")) {
|
||||
LOG_DEBUG("using no init file at all");
|
||||
LOG(DEBUG) << "using no init file at all";
|
||||
} else {
|
||||
configFile = _configFile;
|
||||
}
|
||||
|
@ -321,7 +321,7 @@ void ArangoClient::parse(ProgramOptions& options,
|
|||
configFile = sysDir;
|
||||
allowLocal = true;
|
||||
} else {
|
||||
LOG_DEBUG("no system init file '%s'", sysDir.c_str());
|
||||
LOG(DEBUG) << "no system init file '" << sysDir.c_str() << "'";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -331,7 +331,7 @@ void ArangoClient::parse(ProgramOptions& options,
|
|||
std::string localConfigFile = configFile + ".local";
|
||||
|
||||
if (FileUtils::exists(localConfigFile)) {
|
||||
LOG_DEBUG("using init override file '%s'", localConfigFile.c_str());
|
||||
LOG(DEBUG) << "using init override file '" << localConfigFile.c_str() << "'";
|
||||
|
||||
if (!options.parse(description, localConfigFile)) {
|
||||
LOG_FATAL_AND_EXIT("cannot parse config file '%s': %s",
|
||||
|
@ -341,7 +341,7 @@ void ArangoClient::parse(ProgramOptions& options,
|
|||
}
|
||||
}
|
||||
|
||||
LOG_DEBUG("using init file '%s'", configFile.c_str());
|
||||
LOG(DEBUG) << "using init file '" << configFile.c_str() << "'";
|
||||
|
||||
if (!options.parse(description, configFile)) {
|
||||
LOG_FATAL_AND_EXIT("cannot parse config file '%s': %s",
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
#include "Basics/ConditionLocker.h"
|
||||
#include "Basics/ConditionVariable.h"
|
||||
#include "Basics/hashes.h"
|
||||
#include "Basics/logging.h"
|
||||
#include "Basics/Logger.h"
|
||||
#include "Basics/Thread.h"
|
||||
#include "Benchmark/BenchmarkCounter.h"
|
||||
#include "Benchmark/BenchmarkOperation.h"
|
||||
|
@ -240,7 +240,7 @@ class BenchmarkThread : public arangodb::basics::Thread {
|
|||
const rest::HttpRequest::HttpRequestType type =
|
||||
_operation->type(_threadNumber, threadCounter, globalCounter);
|
||||
if (url.empty()) {
|
||||
LOG_WARNING("URL is empty!");
|
||||
LOG(WARNING) << "URL is empty!";
|
||||
}
|
||||
|
||||
// headline, e.g. POST /... HTTP/1.1
|
||||
|
@ -283,7 +283,7 @@ class BenchmarkThread : public arangodb::basics::Thread {
|
|||
}
|
||||
_warningCount++;
|
||||
if (_warningCount < MaxWarnings) {
|
||||
LOG_WARNING("batch operation failed because server did not reply");
|
||||
LOG(WARNING) << "batch operation failed because server did not reply";
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -293,16 +293,13 @@ class BenchmarkThread : public arangodb::basics::Thread {
|
|||
|
||||
_warningCount++;
|
||||
if (_warningCount < MaxWarnings) {
|
||||
LOG_WARNING("batch operation failed with HTTP code %d - %s ",
|
||||
(int)result->getHttpReturnCode(),
|
||||
result->getHttpReturnMessage().c_str());
|
||||
LOG(WARNING) << "batch operation failed with HTTP code " << result->getHttpReturnCode() << " - " << result->getHttpReturnMessage().c_str() << " ";
|
||||
#ifdef TRI_ENABLE_MAINTAINER_MODE
|
||||
LOG_WARNING("We tried to send this size:\n %llu",
|
||||
(unsigned long long)batchPayload.length());
|
||||
LOG_WARNING("We tried to send this:\n %s", batchPayload.c_str());
|
||||
LOG(WARNING) << "We tried to send this size:\n " << batchPayload.length();
|
||||
LOG(WARNING) << "We tried to send this:\n " << batchPayload.c_str();
|
||||
#endif
|
||||
} else if (_warningCount == MaxWarnings) {
|
||||
LOG_WARNING("...more warnings...");
|
||||
LOG(WARNING) << "...more warnings...";
|
||||
}
|
||||
} else {
|
||||
auto const& headers = result->getHeaderFields();
|
||||
|
@ -315,13 +312,12 @@ class BenchmarkThread : public arangodb::basics::Thread {
|
|||
_operationsCounter->incFailures(errorCount);
|
||||
_warningCount++;
|
||||
if (_warningCount < MaxWarnings) {
|
||||
LOG_WARNING("Server side warning count: %u", errorCount);
|
||||
LOG(WARNING) << "Server side warning count: " << errorCount;
|
||||
if (_verbose) {
|
||||
LOG_WARNING("Server reply: %s", result->getBody().c_str());
|
||||
LOG(WARNING) << "Server reply: " << result->getBody().c_str();
|
||||
#ifdef TRI_ENABLE_MAINTAINER_MODE
|
||||
LOG_WARNING("We tried to send this size:\n %llu",
|
||||
(unsigned long long)batchPayload.length());
|
||||
LOG_WARNING("We tried to send this:\n %s", batchPayload.c_str());
|
||||
LOG(WARNING) << "We tried to send this size:\n " << batchPayload.length();
|
||||
LOG(WARNING) << "We tried to send this:\n " << batchPayload.c_str();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
@ -367,7 +363,7 @@ class BenchmarkThread : public arangodb::basics::Thread {
|
|||
}
|
||||
_warningCount++;
|
||||
if (_warningCount < MaxWarnings) {
|
||||
LOG_WARNING("batch operation failed because server did not reply");
|
||||
LOG(WARNING) << "batch operation failed because server did not reply";
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -377,10 +373,9 @@ class BenchmarkThread : public arangodb::basics::Thread {
|
|||
|
||||
_warningCount++;
|
||||
if (_warningCount < MaxWarnings) {
|
||||
LOG_WARNING("request for URL '%s' failed with HTTP code %d",
|
||||
url.c_str(), (int)result->getHttpReturnCode());
|
||||
LOG(WARNING) << "request for URL '" << url.c_str() << "' failed with HTTP code " << result->getHttpReturnCode();
|
||||
} else if (_warningCount == MaxWarnings) {
|
||||
LOG_WARNING("...more warnings...");
|
||||
LOG(WARNING) << "...more warnings...";
|
||||
}
|
||||
}
|
||||
delete result;
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
#include "Basics/ProgramOptionsDescription.h"
|
||||
#include "Basics/StringUtils.h"
|
||||
#include "Basics/init.h"
|
||||
#include "Basics/logging.h"
|
||||
#include "Basics/Logger.h"
|
||||
#include "Basics/random.h"
|
||||
#include "Basics/StringBuffer.h"
|
||||
#include "Basics/tri-strings.h"
|
||||
|
@ -376,7 +376,7 @@ int main(int argc, char* argv[]) {
|
|||
}
|
||||
|
||||
if (Progress && numOperations >= nextReportValue) {
|
||||
LOG_INFO("number of operations: %d", (int)nextReportValue);
|
||||
LOG(INFO) << "number of operations: " << nextReportValue;
|
||||
nextReportValue += stepValue;
|
||||
}
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
|
||||
#include "Basics/StringUtils.h"
|
||||
#include "Basics/files.h"
|
||||
#include "Basics/Logger.h"
|
||||
#include "Basics/tri-strings.h"
|
||||
#include "Basics/VelocyPackHelper.h"
|
||||
#include "Rest/HttpRequest.h"
|
||||
|
@ -413,15 +414,14 @@ void ImportHelper::reportProgress(int64_t totalLength, int64_t totalRead,
|
|||
static int64_t nextProcessed = 10 * 1000 * 1000;
|
||||
|
||||
if (totalRead >= nextProcessed) {
|
||||
LOG_INFO("processed %lld bytes of input file", (long long)totalRead);
|
||||
LOG(INFO) << "processed " << (long long)totalRead << " bytes of input file";
|
||||
nextProcessed += 10 * 1000 * 1000;
|
||||
}
|
||||
} else {
|
||||
double pct = 100.0 * ((double)totalRead / (double)totalLength);
|
||||
|
||||
if (pct >= nextProgress && totalLength >= 1024) {
|
||||
LOG_INFO("processed %lld bytes (%0.1f%%) of input file",
|
||||
(long long)totalRead, nextProgress);
|
||||
LOG(INFO) << "processed " << totalRead << " bytes (" << (int) nextProgress << "%) of input file";
|
||||
nextProgress = (double)((int)(pct + ProgressStep));
|
||||
}
|
||||
}
|
||||
|
@ -677,7 +677,7 @@ void ImportHelper::handleResult(SimpleHttpResult* result) {
|
|||
if (details.isArray()) {
|
||||
for (VPackSlice const& detail : VPackArrayIterator(details)) {
|
||||
if (detail.isString()) {
|
||||
LOG_WARNING("%s", detail.copyString().c_str());
|
||||
LOG(WARNING) << "" << detail.copyString().c_str();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2296,7 +2296,7 @@ static int WarmupEnvironment(v8::Isolate* isolate,
|
|||
"no 'javascript.startup-directory' has been supplied, giving up");
|
||||
}
|
||||
|
||||
LOG_DEBUG("using JavaScript startup files at '%s'", StartupPath.c_str());
|
||||
LOG(DEBUG) << "using JavaScript startup files at '" << StartupPath.c_str() << "'";
|
||||
StartupLoader.setDirectory(StartupPath);
|
||||
|
||||
// load all init files
|
||||
|
@ -2329,7 +2329,7 @@ static int WarmupEnvironment(v8::Isolate* isolate,
|
|||
for (size_t i = 0; i < files.size(); ++i) {
|
||||
switch (StartupLoader.loadScript(isolate, context, files[i])) {
|
||||
case JSLoader::eSuccess:
|
||||
LOG_TRACE("loaded JavaScript file '%s'", files[i].c_str());
|
||||
LOG(TRACE) << "loaded JavaScript file '" << files[i].c_str() << "'";
|
||||
break;
|
||||
case JSLoader::eFailLoad:
|
||||
LOG_FATAL_AND_EXIT("cannot load JavaScript file '%s'",
|
||||
|
@ -2568,11 +2568,10 @@ int main(int argc, char* args[]) {
|
|||
try {
|
||||
ret = Run(isolate, runMode, promptError);
|
||||
} catch (std::bad_alloc const&) {
|
||||
LOG_ERROR("caught exception %s",
|
||||
TRI_errno_string(TRI_ERROR_OUT_OF_MEMORY));
|
||||
LOG(ERROR) << "caught exception " << TRI_errno_string(TRI_ERROR_OUT_OF_MEMORY);
|
||||
ret = EXIT_FAILURE;
|
||||
} catch (...) {
|
||||
LOG_ERROR("caught unknown exception");
|
||||
LOG(ERROR) << "caught unknown exception";
|
||||
ret = EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
|
@ -2580,9 +2579,9 @@ int main(int argc, char* args[]) {
|
|||
isolate->LowMemoryNotification();
|
||||
|
||||
// spend at least 3 seconds in GC
|
||||
LOG_DEBUG("entering final garbage collection");
|
||||
LOG(DEBUG) << "entering final garbage collection";
|
||||
TRI_RunGarbageCollectionV8(isolate, 3000);
|
||||
LOG_DEBUG("final garbage collection completed");
|
||||
LOG(DEBUG) << "final garbage collection completed";
|
||||
|
||||
localContext->Exit();
|
||||
context.Reset();
|
||||
|
|
Loading…
Reference in New Issue