Skip to content
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

logging: update to work with spdlog 0.11.0 #160

Merged
merged 2 commits into from
Oct 19, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 3 additions & 3 deletions docs/install/requirements.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ Envoy has the following requirements:

* GCC 4.9+ (for C++11 regex support)
* `cotire <https://github.com/sakra/cotire>`_ (last tested with 1.7.8)
* `spdlog <https://github.com/gabime/spdlog>`_ (last tested with 319a62)
* `spdlog <https://github.com/gabime/spdlog>`_ (last tested with 0.11.0)
* `http-parser <https://github.com/nodejs/http-parser>`_ (last tested with 2.7.0)
* `nghttp2 <https://github.com/nghttp2/nghttp2>`_ (last tested with 1.9.2)
* `nghttp2 <https://github.com/nghttp2/nghttp2>`_ (last tested with 1.14.1)
* `libevent <http://libevent.org/>`_ (last tested with 2.0.22)
* `tclap <http://tclap.sourceforge.net/>`_ (last tested with 1.2.1)
* `gperftools <https://github.com/gperftools/gperftools>`_ (last tested with 2.5.0)
* `jansson <https://github.com/akheron/jansson>`_ (last tesed with 2.7)
* `openssl <https://www.openssl.org/>`_ (last tesed with 1.0.2h)
* `openssl <https://www.openssl.org/>`_ (last tesed with 1.0.2i)
* `protobuf <https://github.com/google/protobuf>`_ (last tested with 3.0.0)

In order to compile and run the tests the following is required:
Expand Down
5 changes: 3 additions & 2 deletions docs/operations/cli.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ following are the command line options that Envoy supports.
*(optional)* The number of :ref:`worker threads <arch_overview_threading>` to run. If not
specified defaults to the number of hardware threads on the machine.

.. option:: -l <integer>, --log-level <integer>
.. option:: -l <string>, --log-level <string>

*(optional)* The logging level. Defaults to *NOTICE*. Non developers should never set this option.
*(optional)* The logging level. Non developers should generally never set this option. See the
help text for the available log levels and the default.

.. option:: --restart-epoch <integer>

Expand Down
4 changes: 2 additions & 2 deletions include/envoy/server/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ class Options {
virtual const std::string& configPath() PURE;

/**
* @return uint64_t the default log level for the server.
* @return spdlog::level::level_enum the default log level for the server.
*/
virtual uint64_t logLevel() PURE;
virtual spdlog::level::level_enum logLevel() PURE;

/**
* @return the restart epoch. 0 indicates the first server start, 1 the second, and so on.
Expand Down
5 changes: 3 additions & 2 deletions source/common/common/assert.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
{ \
if (!(X)) { \
Logger::Registry::getLog(Logger::Id::assert) \
.emerg("assert failure: {}: {}:{}", #X, __FILE__, __LINE__); \
.critical("assert failure: {}: {}:{}", #X, __FILE__, __LINE__); \
abort(); \
} \
}
Expand All @@ -29,7 +29,8 @@
* Indicate a panic situation and exit.
*/
#define PANIC(X) \
Logger::Registry::getLog(Logger::Id::assert).emerg("panic: {}: {}:{}", X, __FILE__, __LINE__); \
Logger::Registry::getLog(Logger::Id::assert) \
.critical("panic: {}: {}:{}", X, __FILE__, __LINE__); \
abort();

#define NOT_IMPLEMENTED PANIC("not implemented")
2 changes: 1 addition & 1 deletion source/common/mongo/proxy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ void ProxyFilter::doDecode(Buffer::Instance& buffer) {
try {
decoder_->onData(buffer);
} catch (EnvoyException& e) {
log().notice("mongo decoding error: {}", e.what());
log().info("mongo decoding error: {}", e.what());
stats_.decoding_error_.inc();
sniffing_ = false;
}
Expand Down
2 changes: 1 addition & 1 deletion source/exe/hot_restart.cc
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ void HotRestartImpl::onSocketEvent() {
}

case RpcMessageType::TerminateRequest: {
log().notice("shutting down due to child request");
log().warn("shutting down due to child request");
kill(getpid(), SIGTERM);
break;
}
Expand Down
2 changes: 1 addition & 1 deletion source/exe/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class ProdComponentFactory : public ComponentFactory {
int main(int argc, char** argv) {
Event::Libevent::Global::initialize();
Ssl::OpenSsl::initialize();
OptionsImpl options(argc, argv, Server::SharedMemory::version(), spdlog::level::notice);
OptionsImpl options(argc, argv, Server::SharedMemory::version(), spdlog::level::warn);

std::unique_ptr<Server::HotRestartImpl> restarter;
try {
Expand Down
3 changes: 3 additions & 0 deletions source/precompiled/precompiled.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,7 @@
#include <unistd.h>
#include <unordered_set>

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wold-style-cast"
#include <spdlog/spdlog.h>
#pragma GCC diagnostic pop
6 changes: 3 additions & 3 deletions source/server/config/network/http_connection_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,9 @@ HttpConnectionManagerConfig::HttpConnectionManagerConfig(const Json::Object& con
std::string string_name = filters[i].getString("name");
Json::Object config = filters[i].getObject("config");

log().notice(" filter #{}", i);
log().notice(" type: {}", string_type);
log().notice(" name: {}", string_name);
log().info(" filter #{}", i);
log().info(" type: {}", string_type);
log().info(" name: {}", string_name);

HttpFilterType type = stringToType(string_type);
bool found_filter = false;
Expand Down
18 changes: 9 additions & 9 deletions source/server/configuration_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ void MainImpl::initialize(const std::string& file_path) {
server_.options().serviceZone(), server_.getLocalAddress()));

std::vector<Json::Object> listeners = loader.getObjectArray("listeners");
log().notice("loading {} listener(s)", listeners.size());
log().info("loading {} listener(s)", listeners.size());
for (size_t i = 0; i < listeners.size(); i++) {
log().notice("listener #{}:", i);
log().info("listener #{}:", i);
listeners_.emplace_back(
Server::Configuration::ListenerPtr{new ListenerConfig(*this, listeners[i])});
}
Expand Down Expand Up @@ -61,7 +61,7 @@ void MainImpl::initialize(const std::string& file_path) {
}

void MainImpl::initializeTracers(const Json::Object& tracing_configuration_) {
log().notice("loading tracing configuration");
log().info("loading tracing configuration");

// Initialize http sinks
if (tracing_configuration_.hasObject("http")) {
Expand All @@ -71,11 +71,11 @@ void MainImpl::initializeTracers(const Json::Object& tracing_configuration_) {

if (http_tracer_config.hasObject("sinks")) {
std::vector<Json::Object> sinks = http_tracer_config.getObjectArray("sinks");
log().notice(fmt::format(" loading {} http sink(s):", sinks.size()));
log().info(fmt::format(" loading {} http sink(s):", sinks.size()));

for (const Json::Object& sink : sinks) {
std::string type = sink.getString("type");
log().notice(fmt::format(" loading {}", type));
log().info(fmt::format(" loading {}", type));

if (type == "lightstep") {
::Runtime::RandomGenerator& rand = server_.random();
Expand Down Expand Up @@ -105,7 +105,7 @@ const std::list<Server::Configuration::ListenerPtr>& MainImpl::listeners() { ret

MainImpl::ListenerConfig::ListenerConfig(MainImpl& parent, Json::Object& json)
: parent_(parent), port_(json.getInteger("port")) {
log().notice(" port={}", port_);
log().info(" port={}", port_);

if (json.hasObject("ssl_context")) {
Ssl::ContextConfigImpl context_config(json.getObject("ssl_context"));
Expand All @@ -122,9 +122,9 @@ MainImpl::ListenerConfig::ListenerConfig(MainImpl& parent, Json::Object& json)
std::string string_type = filters[i].getString("type");
std::string string_name = filters[i].getString("name");
Json::Object config = filters[i].getObject("config");
log().notice(" filter #{}:", i);
log().notice(" type: {}", string_type);
log().notice(" name: {}", string_name);
log().info(" filter #{}:", i);
log().info(" type: {}", string_type);
log().info(" name: {}", string_name);

// Map filter type string to enum.
NetworkFilterType type;
Expand Down
2 changes: 1 addition & 1 deletion source/server/drain_manager_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ void DrainManagerImpl::startParentShutdownSequence() {
ASSERT(!parent_shutdown_timer_);
parent_shutdown_timer_ = server_.dispatcher().createTimer([this]() -> void {
// Shut down the parent now. It should have already been draining.
log().notice("shutting down parent after drain");
log().warn("shutting down parent after drain");
server_.hotRestart().terminateParent();
});

Expand Down
22 changes: 19 additions & 3 deletions source/server/options_impl.cc
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
#include "options_impl.h"

#include "common/common/macros.h"
#include "common/common/version.h"

#include "tclap/CmdLine.h"

OptionsImpl::OptionsImpl(int argc, char** argv, const std::string& hot_restart_version,
spdlog::level::level_enum default_log_level) {
std::string log_levels_string = "Log levels: ";
for (size_t i = 0; i < ARRAY_SIZE(spdlog::level::level_names); i++) {
log_levels_string += fmt::format("[{}]", spdlog::level::level_names[i]);
}
log_levels_string +=
fmt::format("\nDefault is [{}]", spdlog::level::level_names[default_log_level]);
log_levels_string += "\n[trace] and [debug] are only available on debug builds";

TCLAP::CmdLine cmd("envoy", ' ', VersionInfo::version());
TCLAP::ValueArg<uint64_t> base_id(
"", "base-id", "base ID so that multiple envoys can run on the same host if needed", false, 0,
Expand All @@ -14,8 +23,9 @@ OptionsImpl::OptionsImpl(int argc, char** argv, const std::string& hot_restart_v
std::thread::hardware_concurrency(), "uint32_t", cmd);
TCLAP::ValueArg<std::string> config_path("c", "config-path", "Path to configuration file", false,
"", "string", cmd);
TCLAP::ValueArg<uint64_t> log_level("l", "log-level", "Log level", false, default_log_level,
"uint64_t", cmd);
TCLAP::ValueArg<std::string> log_level("l", "log-level", log_levels_string, false,
spdlog::level::level_names[default_log_level], "string",
cmd);
TCLAP::ValueArg<uint64_t> restart_epoch("", "restart-epoch", "hot restart epoch #", false, 0,
"uint64_t", cmd);
TCLAP::SwitchArg hot_restart_version_option("", "hot-restart-version",
Expand All @@ -42,11 +52,17 @@ OptionsImpl::OptionsImpl(int argc, char** argv, const std::string& hot_restart_v
exit(0);
}

log_level_ = default_log_level;
for (size_t i = 0; i < ARRAY_SIZE(spdlog::level::level_names); i++) {
if (log_level.getValue() == spdlog::level::level_names[i]) {
log_level_ = static_cast<spdlog::level::level_enum>(i);
}
}

// For base ID, scale what the user inputs by 10 so that we have spread for domain sockets.
base_id_ = base_id.getValue() * 10;
concurrency_ = concurrency.getValue();
config_path_ = config_path.getValue();
log_level_ = log_level.getValue();
restart_epoch_ = restart_epoch.getValue();
service_cluster_ = service_cluster.getValue();
service_node_ = service_node.getValue();
Expand Down
4 changes: 2 additions & 2 deletions source/server/options_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class OptionsImpl : public Server::Options {
uint64_t baseId() { return base_id_; }
uint32_t concurrency() override { return concurrency_; }
const std::string& configPath() override { return config_path_; }
uint64_t logLevel() override { return log_level_; }
spdlog::level::level_enum logLevel() override { return log_level_; }
uint64_t restartEpoch() override { return restart_epoch_; }
const std::string& serviceClusterName() override { return service_cluster_; }
const std::string& serviceNodeName() override { return service_node_; }
Expand All @@ -25,7 +25,7 @@ class OptionsImpl : public Server::Options {
uint64_t base_id_;
uint32_t concurrency_;
std::string config_path_;
uint64_t log_level_;
spdlog::level::level_enum log_level_;
uint64_t restart_epoch_;
std::string service_cluster_;
std::string service_node_;
Expand Down
Loading