Map the logger configuration in lms.conf file
This commit is contained in:
+6
-3
@@ -20,12 +20,15 @@ wt-resources="/usr/share/Wt/resources";
|
||||
docroot = "/usr/share/lms/docroot/;/resources,/css,/images,/js,/favicon.ico";
|
||||
approot = "/usr/share/lms/approot";
|
||||
|
||||
# Turn on this option to allow the demo account creation/use
|
||||
#demo = false;
|
||||
|
||||
# Acoustic brainz's root API
|
||||
acousticbrainz-api-url = "https://acousticbrainz.org/api/v1/";
|
||||
|
||||
# API
|
||||
api-subsonic = true;
|
||||
|
||||
# Logger configuration, see log-config in https://webtoolkit.eu/wt/doc/reference/html/overview.html#config_general
|
||||
log-config = "* -debug -info:WebRequest";
|
||||
|
||||
# Turn on this option to allow the demo account creation/use
|
||||
demo = false;
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
|
||||
namespace Av {
|
||||
|
||||
#define LMS_LOG_TRANSCODE(sev) LMS_LOG(TRANSCODE, INFO) << "[" << _id << "] - "
|
||||
#define LMS_LOG_TRANSCODE(sev) LMS_LOG(TRANSCODE, sev) << "[" << _id << "] - "
|
||||
|
||||
// TODO, parametrize?
|
||||
static const std::vector<std::string> execNames =
|
||||
@@ -179,7 +179,7 @@ Transcoder::start()
|
||||
|
||||
args.push_back("pipe:1");
|
||||
|
||||
LMS_LOG_TRANSCODE(INFO) << "Dumping args (" << args.size() << ")";
|
||||
LMS_LOG_TRANSCODE(DEBUG) << "Dumping args (" << args.size() << ")";
|
||||
for (std::string arg : args)
|
||||
LMS_LOG_TRANSCODE(DEBUG) << "Arg = '" << arg << "'";
|
||||
|
||||
|
||||
+1
-2
@@ -70,6 +70,7 @@ std::vector<std::string> generateWtConfig(std::string execPath)
|
||||
|
||||
pt.put("server.application-settings.<xmlattr>.location", "*");
|
||||
pt.put("server.application-settings.log-file", wtLogFilePath.string());
|
||||
pt.put("server.application-settings.log-config", Config::instance().getString("log-level", "info -info:WebRequest"));
|
||||
pt.put("server.application-settings.behind-reverse-proxy", Config::instance().getBool("behind-reverse-proxy", false));
|
||||
pt.put("server.application-settings.progressive-bootstrap", true);
|
||||
|
||||
@@ -115,8 +116,6 @@ int main(int argc, char* argv[])
|
||||
Wt::WServer server(argv[0]);
|
||||
server.setServerConfiguration (wtServerArgs.size(), const_cast<char**>(wtArgv));
|
||||
|
||||
Wt::WServer::instance()->logger().configure("*"); // log everything, TODO configure this
|
||||
|
||||
// lib init
|
||||
Image::init(argv[0]);
|
||||
Av::AvInit();
|
||||
|
||||
@@ -242,7 +242,6 @@ MediaScanner::requestImmediateScan()
|
||||
{
|
||||
_ioService.post([=]()
|
||||
{
|
||||
LMS_LOG(DBUPDATER, INFO) << "Schedule immediate scan";
|
||||
scheduleScan();
|
||||
});
|
||||
}
|
||||
@@ -252,7 +251,6 @@ MediaScanner::requestReschedule()
|
||||
{
|
||||
_ioService.post([=]()
|
||||
{
|
||||
LMS_LOG(DBUPDATER, INFO) << "Rescheduling scan";
|
||||
scheduleNextScan();
|
||||
});
|
||||
}
|
||||
@@ -274,6 +272,8 @@ MediaScanner::getStatus()
|
||||
void
|
||||
MediaScanner::scheduleNextScan()
|
||||
{
|
||||
LMS_LOG(DBUPDATER, INFO) << "Scheduling next scan";
|
||||
|
||||
refreshScanSettings();
|
||||
|
||||
Wt::WDateTime now = Wt::WLocalDateTime::currentServerDateTime().toUTC();
|
||||
|
||||
@@ -562,7 +562,7 @@ static std::string escape(std::string str)
|
||||
void
|
||||
LmsApplication::notifyMsg(MsgType type, const Wt::WString& message, std::chrono::milliseconds duration)
|
||||
{
|
||||
LMS_LOG(UI, INFO) << "Notifying message '" << message.toUTF8() << "' of type '" << msgTypeToString(type);
|
||||
LMS_LOG(UI, INFO) << "Notifying message '" << message.toUTF8() << "' of type '" << msgTypeToString(type) << "'";
|
||||
|
||||
std::ostringstream oss;
|
||||
|
||||
|
||||
+17
-25
@@ -21,20 +21,8 @@
|
||||
|
||||
#include <sstream>
|
||||
|
||||
namespace {
|
||||
#include "utils/Logger.hpp"
|
||||
|
||||
}
|
||||
|
||||
Config::Config()
|
||||
: _config (nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
Config::~Config()
|
||||
{
|
||||
if (_config)
|
||||
delete _config;
|
||||
}
|
||||
|
||||
Config&
|
||||
Config::instance()
|
||||
@@ -44,21 +32,25 @@ Config::instance()
|
||||
}
|
||||
|
||||
void
|
||||
Config::setFile(boost::filesystem::path p)
|
||||
Config::setFile(const boost::filesystem::path& p)
|
||||
{
|
||||
if (_config != nullptr)
|
||||
delete _config;
|
||||
|
||||
_config = new libconfig::Config();
|
||||
|
||||
_config = std::make_unique<libconfig::Config>();
|
||||
_config->readFile(p.string().c_str());
|
||||
}
|
||||
|
||||
std::string
|
||||
Config::getString(std::string setting, std::string def)
|
||||
Config::getString(const std::string& setting, const std::string& def, const std::set<std::string>& allowedValues)
|
||||
{
|
||||
try {
|
||||
return _config->lookup(setting);
|
||||
std::string res {(const char*)_config->lookup(setting)};
|
||||
|
||||
if (!allowedValues.empty() && allowedValues.find(res) == allowedValues.end())
|
||||
{
|
||||
LMS_LOG(MAIN, ERROR) << "Invalid setting for '" << setting << "', using default value '" << def << "'";
|
||||
return def;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
catch (std::exception &e)
|
||||
{
|
||||
@@ -67,7 +59,7 @@ Config::getString(std::string setting, std::string def)
|
||||
}
|
||||
|
||||
boost::filesystem::path
|
||||
Config::getPath(std::string setting, boost::filesystem::path path)
|
||||
Config::getPath(const std::string& setting, const boost::filesystem::path& path)
|
||||
{
|
||||
try {
|
||||
const char* res = _config->lookup(setting);
|
||||
@@ -80,7 +72,7 @@ Config::getPath(std::string setting, boost::filesystem::path path)
|
||||
}
|
||||
|
||||
unsigned long
|
||||
Config::getULong(std::string setting, unsigned long def)
|
||||
Config::getULong(const std::string& setting, unsigned long def)
|
||||
{
|
||||
try {
|
||||
return static_cast<unsigned int>(_config->lookup(setting));
|
||||
@@ -92,7 +84,7 @@ Config::getULong(std::string setting, unsigned long def)
|
||||
}
|
||||
|
||||
long
|
||||
Config::getLong(std::string setting, long def)
|
||||
Config::getLong(const std::string& setting, long def)
|
||||
{
|
||||
try {
|
||||
return _config->lookup(setting);
|
||||
@@ -104,7 +96,7 @@ Config::getLong(std::string setting, long def)
|
||||
}
|
||||
|
||||
bool
|
||||
Config::getBool(std::string setting, bool def)
|
||||
Config::getBool(const std::string& setting, bool def)
|
||||
{
|
||||
try {
|
||||
return _config->lookup(setting);
|
||||
|
||||
+12
-10
@@ -18,34 +18,36 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <set>
|
||||
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <libconfig.h++>
|
||||
|
||||
// Used to get config values from configuration files
|
||||
class Config
|
||||
class Config final
|
||||
{
|
||||
public:
|
||||
|
||||
Config(const Config&) = delete;
|
||||
Config& operator=(const Config&) = delete;
|
||||
Config(Config&&) = delete;
|
||||
Config& operator=(Config&&) = delete;
|
||||
|
||||
static Config& instance();
|
||||
|
||||
void setFile(boost::filesystem::path p);
|
||||
void setFile(const boost::filesystem::path& p);
|
||||
|
||||
// Default values are returned in case of setting not found
|
||||
std::string getString(std::string setting, std::string def = "");
|
||||
boost::filesystem::path getPath(std::string setting, boost::filesystem::path def = boost::filesystem::path());
|
||||
unsigned long getULong(std::string setting, unsigned long def = 0);
|
||||
long getLong(std::string setting, long def = 0);
|
||||
bool getBool(std::string setting, bool def = false);
|
||||
std::string getString(const std::string& setting, const std::string& def = "", const std::set<std::string>& allowedValues = {});
|
||||
boost::filesystem::path getPath(const std::string& setting, const boost::filesystem::path& def = boost::filesystem::path());
|
||||
unsigned long getULong(const std::string& setting, unsigned long def = 0);
|
||||
long getLong(const std::string& setting, long def = 0);
|
||||
bool getBool(const std::string& setting, bool def = false);
|
||||
|
||||
private:
|
||||
|
||||
Config();
|
||||
~Config();
|
||||
Config() = default;
|
||||
|
||||
libconfig::Config *_config;
|
||||
std::unique_ptr<libconfig::Config> _config;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user