diff --git a/config/tawashi.ini b/config/tawashi.ini
index 34346ac..6f0ac7e 100644
--- a/config/tawashi.ini
+++ b/config/tawashi.ini
@@ -4,3 +4,4 @@ redis_port = 6379
redis_mode = inet
base_uri = http://127.0.0.1:8080
website_root = /home/michele/dev/code/cpp/tawashi/html
+logging_level = trace
diff --git a/src/logging_levels.hpp b/src/logging_levels.hpp
new file mode 100644
index 0000000..8b52bbb
--- /dev/null
+++ b/src/logging_levels.hpp
@@ -0,0 +1,33 @@
+/* Copyright 2017, Michele Santullo
+ * This file is part of "tawashi".
+ *
+ * "tawashi" is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * "tawashi" is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with "tawashi". If not, see .
+ */
+
+#pragma once
+
+#include "enum.h"
+#include
+
+namespace tawashi {
+ BETTER_ENUM(LoggingLevels, int,
+ trace = spdlog::level::trace,
+ debug = spdlog::level::debug,
+ info = spdlog::level::info,
+ warn = spdlog::level::warn,
+ err = spdlog::level::err,
+ critical = spdlog::level::critical,
+ off = spdlog::level::off
+ );
+} //namespace tawashi
diff --git a/src/main.cpp b/src/main.cpp
index f0e9193..8c30f26 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -26,6 +26,7 @@
#include "pathname/pathname.hpp"
#include "duckhandy/compatibility.h"
#include "settings_bag.hpp"
+#include "logging_levels.hpp"
#include
#include
#include
@@ -68,6 +69,7 @@ namespace {
parSettings.add_default("min_pastie_size", "10");
parSettings.add_default("max_pastie_size", "10000");
parSettings.add_default("truncate_long_pasties", "false");
+ parSettings.add_default("logging_level", "err");
}
} //unnamed namespace
@@ -80,7 +82,7 @@ int main() {
//Prepare the logger
spdlog::set_pattern("[%Y-%m-%d %T %z] - %v");
- spdlog::set_level(spdlog::level::debug);
+ spdlog::set_level(spdlog::level::trace); //set to maximum possible here
auto statuslog = spdlog::stderr_logger_st("statuslog");
statuslog->debug("Loading config: \"{}\"\n", config_file_path());
@@ -93,6 +95,11 @@ int main() {
auto settings = SafeStackObject(ini);
fill_defaults(*settings);
+ {
+ auto logging_level = tawashi::LoggingLevels::_from_string_nocase(settings->as("logging_level").c_str());
+ spdlog::set_level(static_cast(logging_level._to_integral()));
+ }
+
tawashi::cgi::Env cgi_env;
tawashi::ResponseFactory resp_factory(settings);
resp_factory.register_maker("index.cgi", &make_response);