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