8000 Bug fix/fixes 0609 by jsteemann · Pull Request #3227 · arangodb/arangodb · GitHub
[go: up one dir, main page]

Skip to content

Bug fix/fixes 0609 #3227

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 55 commits into from
Sep 13, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
c080632
do not use V8 variant of AQL functions in early optimization stage wh…
jsteemann Sep 6, 2017
358356c
added missing space in warning message
jsteemann Sep 6, 2017
b23b85f
make line-counting more efficient
jsteemann Sep 6, 2017
512f549
removed unused includes
jsteemann Sep 6, 2017
b6ebf9d
remove duplicate V8 context number control variables
jsteemann Sep 6, 2017
03ed4f8
warn when more than 90% of max mappings are in use
jsteemann Sep 6, 2017
efb3a17
added C++ variant of replication catchup
jsteemann Sep 6, 2017
cdfc90c
speed up test
jsteemann Sep 6, 2017
a6d1923
speed up test
jsteemann Sep 6, 2017
2b72b90
speed up test
jsteemann Sep 7, 2017
db9bb73
make ctor explicit
jsteemann Sep 7, 2017
7965c94
V8 macro cleanup, StringBuffer optimizations
jsteemann Sep 7, 2017
d2bbd0d
Merge branch 'devel' of https://github.com/arangodb/arangodb into bug…
jsteemann Sep 7, 2017
4fe6779
fix a deadlock
jsteemann Sep 7, 2017
e57e2ef
added `--log.role` option
jsteemann Sep 7, 2017
7a0151e
updated CHANGELOG
jsteemann Sep 7, 2017
024327a
Merge branch 'devel' of https://github.com/arangodb/arangodb into bug…
jsteemann Sep 7, 2017
92f398f
removed useless vector for authentication...
jsteemann Sep 7, 2017
cd03efb
removed non-existing scheduler.threads option from config
jsteemann Sep 7, 2017
9bc0bab
removed several occurrences of TRI_CORE_MEM_ZONE
jsteemann Sep 7, 2017 8000
17be850
Merge branch 'devel' of https://github.com/arangodb/arangodb into bug…
jsteemann Sep 7, 2017
967f0e0
jslint
jsteemann Sep 7, 2017
e13bbd5
fix include order
jsteemann Sep 7, 2017
90b5915
Merge branch 'devel' of https://github.com/arangodb/arangodb into bug…
jsteemann Sep 7, 2017
86e29db
remove JavaScript-based replication remainders
jsteemann Sep 7, 2017
5c4aa5a
use correct database
jsteemann Sep 7, 2017
44fdadb
some fixes for replication
jsteemann Sep 7, 2017
d2f86e8
removed useless __FILE__, __LINE__ invocations
jsteemann Sep 8, 2017
f0cd8a2
micro optimizations
jsteemann Sep 8, 2017
2d3dc23
joyful colorized logs
jsteemann Sep 8, 2017
88bccfe
Merge branch 'devel' of https://github.com/arangodb/arangodb into bug…
jsteemann Sep 8, 2017
fbc66bd
fix typo
jsteemann Sep 8, 2017
95f13a6
port some of the non-yet-ready cluster optimization rules
jsteemann Sep 8, 2017
3bda7d0
updated CHANGELOG
jsteemann Sep 8, 2017
6140c3e
allow a priority V8 context
jsteemann Sep 8, 2017
a163c3f
use functions to generate V8 strings, so we can add error reporting t…
jsteemann Sep 8, 2017
3620043
fix assertion failure
jsteemann Sep 11, 2017
229b90d
Merge branch 'devel' of https://github.com/arangodb/arangodb into bug…
jsteemann Sep 11, 2017
5b217e7
updated CHANGELOG
jsteemann Sep 12, 2017
fff754c
updated CHANGELOG
jsteemann Sep 12, 2017
e3a1931
remove TRI_CORE_MEM_ZONE
jsteemann Sep 12, 2017
a6f674b
Merge branch 'devel' of https://github.com/arangodb/arangodb into bug…
jsteemann Sep 12, 2017
63c24f1
try to fix Windows errors & warnings
jsteemann Sep 12, 2017
f8a4832
cleanup
jsteemann Sep 12, 2017
ce160c7
Merge branch 'devel' of https://github.com/arangodb/arangodb into bug…
jsteemann Sep 12, 2017
aae4846
removed memory zones altogether
jsteemann Sep 13, 2017
6f1086c
Merge branch 'devel' of https://github.com/arangodb/arangodb into bug…
jsteemann Sep 13, 2017
4e7ba81
Merge branch 'devel' of https://github.com/arangodb/arangodb into bug…
jsteemann Sep 13, 2017
ecd866f
fix Visual Studio warnings
jsteemann Sep 13, 2017
f2ffc27
fix MSVC compile error
jsteemann Sep 13, 2017
ca29268
micro optimizations
jsteemann Sep 13, 2017
55a8c65
try to fix compile error
jsteemann Sep 13, 2017
125d126
revert some potential performance improvements. does not compile ever…
jsteemann Sep 13, 2017
f4e86b9
wait dynamically
jsteemann Sep 13, 2017
a556dcb
exclude system collections from collection tests
jsteemann Sep 13, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
joyful colorized logs
  • Loading branch information
jsteemann committed Sep 8, 2017
commit 2d3dc2349660fc5691425fda54c7c083b9f9f37c
9 changes: 6 additions & 3 deletions lib/ApplicationFeatures/ShellColorsFeature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,16 @@
////////////////////////////////////////////////////////////////////////////////

#include "ShellColorsFeature.h"
#

#ifdef _WIN32
#include "Basics/win-utils.h"
#endif

using namespace arangodb;
using namespace arangodb::basics;

namespace {
static char const* NoColor = "";
static char const* NoColor = "";
}

char const* ShellColorsFeature::SHELL_COLOR_RED = NoColor;
Expand Down Expand Up @@ -82,7 +86,6 @@ void ShellColorsFeature::prepare() {

bool ShellColorsFeature::useColors() {
#ifdef _WIN32
#include "Basics/win-utils.h"
return terminalKnowsANSIColors();
#else
return true;
Expand Down
1 change: 0 additions & 1 deletion lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@ add_library(${LIB_ARANGO} STATIC
Logger/LogAppender.cpp
Logger/LogAppenderFile.cpp
Logger/LogAppenderSyslog.cpp
Logger/LogAppenderTty.cpp
Logger/LogBuffer.cpp
Logger/LogLevel.cpp
Logger/LogThread.cpp
8000 Expand Down
66 changes: 24 additions & 42 deletions lib/Logger/LogAppender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,13 @@
#include "Basics/StringUtils.h"
#include "Logger/LogAppenderFile.h"
#include "Logger/LogAppenderSyslog.h"
#include "Logger/LogAppenderTty.h"
#include "Logger/Logger.h"

using namespace arangodb;
using namespace arangodb::basics;

arangodb::Mutex LogAppender::_appendersLock;

std::unique_ptr<LogAppender> LogAppender::_ttyAppender(nullptr);

std::map<size_t, std::vector<std::shared_ptr<LogAppender>>>
LogAppender::_topics2appenders;

Expand All @@ -63,18 +60,18 @@ void LogAppender::addAppender(std::string const& definition,

LogTopic* topic = appender.second;
size_t n = (topic == nullptr) ? LogTopic::MAX_LOG_TOPICS : topic->id();
_topics2appenders[n].emplace_back(appender.first);
if (std::find(_topics2appenders[n].begin(), _topics2appenders[n].end(), appender.first) == _topics2appenders[n].end()) {
_topics2appenders[n].emplace_back(appender.first);
}
}

void LogAppender::addTtyAppender() { _ttyAppender.reset(new LogAppenderTty()); }

std::pair<std::shared_ptr<LogAppender>, LogTopic*> LogAppender::buildAppender(
std::string const& definition, std::string const& filter) {
std::vector<std::string> v = StringUtils::split(definition, '=', '\0');
std::string topicName;
std::string output;
std::string contentFilter;

if (v.size() == 1) {
output = v[0];
contentFilter = filter;
Expand Down Expand Up @@ -143,20 +140,30 @@ std::pair<std::shared_ptr<LogAppender>, LogTopic*> LogAppender::buildAppender(
}
#endif

// everything else must be file-based logging
std::string filename;
if (output == "+" || output == "-") {
for (auto const& it : _definition2appenders) {
if (it.first.first == "+" || it.first.first == "-") {
// alreay got a logger for stderr/stdout
return {nullptr, nullptr};
}
}
}

if (output == "-" || output == "+") {
filename = output;
// everything else must be file-/stream-based logging
std::shared_ptr<LogAppenderStream> result;

if (output == "+") {
result.reset(new LogAppenderStderr(contentFilter));
} else if (output == "-") {
result.reset(new LogAppenderStdout(contentFilter));
} else if (StringUtils::isPrefix(output, "file://")) {
filename = output.substr(7);
result.reset(new LogAppenderFile(output.substr(7), contentFilter));
} else {
LOG_TOPIC(ERR, arangodb::Logger::FIXME) << "unknown output definition '" << output << "'";
return {nullptr, nullptr};
}

try {
auto result = std::make_shared<LogAppenderFile>(filename, contentFilter);
_definition2appenders[key] = result;

return {result, topic};
Expand All @@ -171,12 +178,11 @@ void LogAppender::log(LogMessage* message) {
size_t topicId = message->_topicId;
std::string const& m = message->_message;
size_t offset = message->_offset;
bool shownStd = false;

MUTEX_LOCKER(guard, _appendersLock);

// output to appender
auto output = [&level, &m, &offset, &shownStd](size_t n) -> bool {
auto output = [&level, &m, &offset](size_t n) -> bool {
auto const& it = _topics2appenders.find(n);
bool shown = false;

Expand All @@ -185,8 +191,7 @@ void LogAppender::log(LogMessage* message) {

for (auto const& appender : appenders) {
if (appender->checkContent(m)) {
bool s = appender->logMessage(level, m, offset);
shownStd |= s;
appender->logMessage(level, m, offset);
}

shown = true;
Expand All @@ -208,46 +213,23 @@ void LogAppender::log(LogMessage* message) {
shown = output(LogTopic::MAX_LOG_TOPICS);
}

if (_ttyAppender != nullptr && !shownStd) {
_ttyAppender->logMessage(level, m, offset);
shown = true;
}

if (!shown) {
writeStderr(level, m);
}

for (auto const& logger : _loggers) {
logger(message);
}
}

void LogAppender::writeStderr(LogLevel level, std::string const& msg) {
if (level == LogLevel::FATAL) {
fprintf(stderr, "%s%s%s\n", ShellColorsFeature::SHELL_COLOR_RED, msg.c_str(), ShellColorsFeature::SHELL_COLOR_RESET);
} else if (level == LogLevel::ERR) {
fprintf(stderr, "%s%s%s\n", ShellColorsFeature::SHELL_COLOR_RED, msg.c_str(), ShellColorsFeature::SHELL_COLOR_RESET);
fflush(stderr);
} else if (level == LogLevel::WARN) {
fprintf(stderr, "%s%s%s\n", ShellColorsFeature::SHELL_COLOR_YELLOW, msg.c_str(), ShellColorsFeature::SHELL_COLOR_RESET);
} else {
fprintf(stderr, "%s\n", msg.c_str());
}
}

void LogAppender::shutdown() {
MUTEX_LOCKER(guard, _appendersLock);

LogAppenderSyslog::close();
LogAppenderFile::close();
LogAppenderFile::closeAll();

_topics2appenders.clear();
_definition2appenders.clear();
_ttyAppender.reset(nullptr);
}

void LogAppender::reopen() {
MUTEX_LOCKER(guard, _appendersLock);

LogAppenderFile::reopen();
LogAppenderFile::reopenAll();
}
7 changes: 1 addition & 6 deletions lib/Logger/LogAppender.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
#include "Basics/Common.h"

#include "Basics/Mutex.h"
#include "Basics/tri-strings.h"
#include "Logger/LogLevel.h"

namespace arangodb {
Expand All @@ -40,13 +39,11 @@ class LogAppender {

static void addAppender(std::string const& definition,
std::string const& contentFilter = "");
static void addTtyAppender();

static std::pair<std::shared_ptr<LogAppender>, LogTopic*> buildAppender(
std::string const& definition, std::string const& contentFilter);

static void log(LogMessage*);
static void writeStderr(LogLevel, std::string const&);

static void reopen();
static void shutdown();
Expand All @@ -67,16 +64,14 @@ class LogAppender {
}

bool checkContent(std::string const& message) {
return _filter.empty() ||
TRI_IsContainedString(message.c_str(), _filter.c_str());
return _filter.empty() || (message.find(_filter) != std::string::npos);
}

protected:
std::string const _filter; // an optional content filter for log messages

private:
static Mutex _appendersLock;
static std::unique_ptr<LogAppender> _ttyAppender;
static std::map<size_t, std::vector<std::shared_ptr<LogAppender>>>
_topics2appenders;
static std::map<std::pair<std::string, std::string>,
Expand Down
Loading
0