Updated Logger to use enum class

This commit is contained in:
epoupon
2015-09-11 17:58:10 +02:00
parent c94c859f68
commit 9ebedd5bfc
26 changed files with 139 additions and 141 deletions
+7 -7
View File
@@ -53,7 +53,7 @@ void AvInit()
/* register all the codecs */
avcodec_register_all();
av_register_all();
LMS_LOG(MOD_AV, SEV_INFO) << "avcodec version = " << avcodec_version();
LMS_LOG(AV, INFO) << "avcodec version = " << avcodec_version();
}
@@ -79,7 +79,7 @@ MediaFile::open(void)
int error = avformat_open_input(&_context, _p.string().c_str(), nullptr, nullptr);
if (error < 0)
{
LMS_LOG(MOD_AV, SEV_ERROR) << "Cannot open '" << _p.string() << "', avformat_open_input returned " << averror_to_string(error);
LMS_LOG(AV, ERROR) << "Cannot open '" << _p.string() << "', avformat_open_input returned " << averror_to_string(error);
return false;
}
@@ -95,7 +95,7 @@ MediaFile::scan(void)
int error = avformat_find_stream_info(_context, nullptr);
if (error < 0)
{
LMS_LOG(MOD_AV, SEV_ERROR) << "Cannot find stream information: '" << averror_to_string(error);
LMS_LOG(AV, ERROR) << "Cannot find stream information: '" << averror_to_string(error);
return false;
}
@@ -171,7 +171,7 @@ MediaFile::getStreams(Stream::Type type) const
if (avstream->codec == nullptr)
{
LMS_LOG(MOD_AV, SEV_ERROR) << "Skipping stream " << i << " since no codec is set";
LMS_LOG(AV, ERROR) << "Skipping stream " << i << " since no codec is set";
continue;
}
@@ -226,7 +226,7 @@ MediaFile::getBestStreamId(Stream::Type type) const
0);
if (res < 0)
{
LMS_LOG(MOD_AV, SEV_ERROR) << "Cannot find best stream for type " << streamType_to_string(type);
LMS_LOG(AV, ERROR) << "Cannot find best stream for type " << streamType_to_string(type);
return -1;
}
@@ -273,7 +273,7 @@ MediaFile::getAttachedPictures(std::size_t nbMaxPictures) const
if (avstream->codec == nullptr)
{
LMS_LOG(MOD_AV, SEV_ERROR) << "Skipping stream " << i << " since no codec is set";
LMS_LOG(AV, ERROR) << "Skipping stream " << i << " since no codec is set";
continue;
}
@@ -287,7 +287,7 @@ MediaFile::getAttachedPictures(std::size_t nbMaxPictures) const
else
{
picture.mimeType = "application/octet-stream";
LMS_LOG(MOD_AV, SEV_ERROR) << "CODEC ID " << avstream->codec->codec_id << " not handled in mime type conversion";
LMS_LOG(AV, ERROR) << "CODEC ID " << avstream->codec->codec_id << " not handled in mime type conversion";
}
AVPacket pkt = avstream->attached_pic;
+11 -11
View File
@@ -66,7 +66,7 @@ Transcoder::init()
}
if (!_avConvPath.empty())
LMS_LOG(MOD_TRANSCODE, SEV_INFO) << "Using transcoder " << _avConvPath;
LMS_LOG(TRANSCODE, INFO) << "Using transcoder " << _avConvPath;
else
throw std::runtime_error("Cannot find any transcoder binary!");
}
@@ -94,7 +94,7 @@ Transcoder::start()
else if (!boost::filesystem::is_regular( _filePath) )
return false;
LMS_LOG(MOD_TRANSCODE, SEV_INFO) << "Transcoding file '" << _filePath << "'";
LMS_LOG(TRANSCODE, INFO) << "Transcoding file '" << _filePath << "'";
// Launch a process to handle the conversion
boost::iostreams::file_descriptor_sink sink(_outputPipe.sink, boost::iostreams::close_handle);
@@ -157,7 +157,7 @@ Transcoder::start()
}
oss << " -"; // output to stdout
LMS_LOG(MOD_TRANSCODE, SEV_DEBUG) << "Executing '" << oss.str() << "'";
LMS_LOG(TRANSCODE, DEBUG) << "Executing '" << oss.str() << "'";
// make sure only one thread is executing this part of code
// See boost process FAQ
@@ -191,7 +191,7 @@ Transcoder::process(std::vector<unsigned char>& output, std::size_t maxSize)
}
if (!_in || _in.fail() || _in.eof()) {
LMS_LOG(MOD_TRANSCODE, SEV_DEBUG) << "Transcode complete!";
LMS_LOG(TRANSCODE, DEBUG) << "Transcode complete!";
waitChild();
_isComplete = true;
@@ -201,7 +201,7 @@ Transcoder::process(std::vector<unsigned char>& output, std::size_t maxSize)
Transcoder::~Transcoder()
{
LMS_LOG(MOD_TRANSCODE, SEV_DEBUG) << "~Transcoder called!";
LMS_LOG(TRANSCODE, DEBUG) << "~Transcoder called!";
if (_in.eof())
waitChild();
@@ -216,12 +216,12 @@ Transcoder::waitChild()
{
boost::system::error_code ec;
LMS_LOG(MOD_TRANSCODE, SEV_DEBUG) << "Waiting for child...";
LMS_LOG(TRANSCODE, DEBUG) << "Waiting for child...";
boost::process::wait_for_exit(*_child, ec);
LMS_LOG(MOD_TRANSCODE, SEV_DEBUG) << "Waiting for child: OK";
LMS_LOG(TRANSCODE, DEBUG) << "Waiting for child: OK";
if (ec)
LMS_LOG(MOD_TRANSCODE, SEV_ERROR) << "Transcoder::waitChild: error: " << ec.message();
LMS_LOG(TRANSCODE, ERROR) << "Transcoder::waitChild: error: " << ec.message();
_child.reset();
}
@@ -234,13 +234,13 @@ Transcoder::killChild()
{
boost::system::error_code ec;
LMS_LOG(MOD_TRANSCODE, SEV_DEBUG) << "Killing child! pid = " << _child->pid;
LMS_LOG(TRANSCODE, DEBUG) << "Killing child! pid = " << _child->pid;
boost::process::terminate(*_child, ec);
LMS_LOG(MOD_TRANSCODE, SEV_DEBUG) << "Killing child DONE";
LMS_LOG(TRANSCODE, DEBUG) << "Killing child DONE";
// If an error occured, force kill the child
if (ec)
LMS_LOG(MOD_TRANSCODE, SEV_ERROR) << "Transcoder::killChild: error: " << ec.message();
LMS_LOG(TRANSCODE, ERROR) << "Transcoder::killChild: error: " << ec.message();
_child.reset();
}
+1 -1
View File
@@ -71,7 +71,7 @@ CoverArt::scale(std::size_t size)
}
catch(std::exception& e)
{
LMS_LOG(MOD_COVER, SEV_ERROR) << "Caught exception: " << e.what();
LMS_LOG(COVER, ERROR) << "Caught exception: " << e.what();
}
return res;
+1 -1
View File
@@ -112,7 +112,7 @@ Grabber::getCoverPaths(const boost::filesystem::path& directoryPath, std::size_t
if (boost::filesystem::file_size(path) > _maxFileSize)
{
LMS_LOG(MOD_COVER, SEV_INFO) << "Cover file '" << path << " is too big (" << boost::filesystem::file_size(path) << "), limit is " << _maxFileSize;
LMS_LOG(COVER, INFO) << "Cover file '" << path << " is too big (" << boost::filesystem::file_size(path) << "), limit is " << _maxFileSize;
continue;
}
+1 -1
View File
@@ -47,7 +47,7 @@ void computeCrc(const boost::filesystem::path& p, std::vector<unsigned char>& cr
}
else
{
LMS_LOG(MOD_DBUPDATER, SEV_ERROR) << "Failed to open file '" << p << "'";
LMS_LOG(DBUPDATER, ERROR) << "Failed to open file '" << p << "'";
throw std::runtime_error("Failed to open file '" + p.string() + "'" );
}
+32 -32
View File
@@ -154,7 +154,7 @@ Updater::processNextJob(void)
MediaDirectorySettings::pointer settings = MediaDirectorySettings::get(_db.getSession());
if (settings->getManualScanRequested()) {
LMS_LOG(MOD_DBUPDATER, SEV_NOTICE) << "Manual scan requested!";
LMS_LOG(DBUPDATER, INFO) << "Manual scan requested!";
scheduleScan( boost::posix_time::seconds(0) );
}
else
@@ -197,7 +197,7 @@ Updater::processNextJob(void)
void
Updater::scheduleScan( boost::posix_time::time_duration duration)
{
LMS_LOG(MOD_DBUPDATER, SEV_NOTICE) << "Scheduling next scan in " << duration;
LMS_LOG(DBUPDATER, INFO) << "Scheduling next scan in " << duration;
_scheduleTimer.expires_from_now(duration);
_scheduleTimer.async_wait( boost::bind( &Updater::process, this, boost::asio::placeholders::error) );
}
@@ -205,7 +205,7 @@ Updater::scheduleScan( boost::posix_time::time_duration duration)
void
Updater::scheduleScan( boost::posix_time::ptime time)
{
LMS_LOG(MOD_DBUPDATER, SEV_NOTICE) << "Scheduling next scan at " << time;
LMS_LOG(DBUPDATER, INFO) << "Scheduling next scan at " << time;
_scheduleTimer.expires_at(time);
_scheduleTimer.async_wait( boost::bind( &Updater::process, this, boost::asio::placeholders::error) );
}
@@ -230,12 +230,12 @@ Updater::process(boost::system::error_code err)
for (RootDirectory rootDirectory : rootDirectories)
{
LMS_LOG(MOD_DBUPDATER, SEV_INFO) << "Processing root directory '" << rootDirectory.path << "'...";
LMS_LOG(DBUPDATER, INFO) << "Processing root directory '" << rootDirectory.path << "'...";
processRootDirectory(rootDirectory, stats);
LMS_LOG(MOD_DBUPDATER, SEV_INFO) << "Processing root directory '" << rootDirectory.path << "' DONE";
LMS_LOG(DBUPDATER, INFO) << "Processing root directory '" << rootDirectory.path << "' DONE";
}
LMS_LOG(MOD_DBUPDATER, SEV_INFO) << "Scan complete. Changes = " << stats.nbChanges() << ", Errors = " << stats.nbScanErrors;
LMS_LOG(DBUPDATER, INFO) << "Scan complete. Changes = " << stats.nbChanges() << ", Errors = " << stats.nbScanErrors;
// Update database stats
boost::posix_time::ptime now = boost::posix_time::second_clock::local_time();
@@ -396,7 +396,7 @@ Updater::processAudioFile( const boost::filesystem::path& file, Stats& stats)
if (items.find(MetaData::Type::AudioStreams) == items.end()
|| boost::any_cast<std::vector<MetaData::AudioStream> >(items[MetaData::Type::AudioStreams]).empty())
{
LMS_LOG(MOD_DBUPDATER, SEV_DEBUG) << "Skipped '" << file << "' (no audio stream found)";
LMS_LOG(DBUPDATER, DEBUG) << "Skipped '" << file << "' (no audio stream found)";
// If Track exists here, delete it!
if (track) {
@@ -408,7 +408,7 @@ Updater::processAudioFile( const boost::filesystem::path& file, Stats& stats)
if (items.find(MetaData::Type::Duration) == items.end()
|| boost::any_cast<boost::posix_time::time_duration>(items[MetaData::Type::Duration]).total_seconds() <= 0)
{
LMS_LOG(MOD_DBUPDATER, SEV_DEBUG) << "Skipped '" << file << "' (no duration or duration <= 0)";
LMS_LOG(DBUPDATER, DEBUG) << "Skipped '" << file << "' (no duration or duration <= 0)";
// If Track exists here, delete it!
if (track) {
@@ -481,12 +481,12 @@ Updater::processAudioFile( const boost::filesystem::path& file, Stats& stats)
{
// Create a new song
track = Track::create(_db.getSession(), file);
LMS_LOG(MOD_DBUPDATER, SEV_INFO) << "Adding '" << file << "'";
LMS_LOG(DBUPDATER, INFO) << "Adding '" << file << "'";
stats.nbAdded++;
}
else
{
LMS_LOG(MOD_DBUPDATER, SEV_INFO) << "Updating '" << file << "'";
LMS_LOG(DBUPDATER, INFO) << "Updating '" << file << "'";
stats.nbModified++;
}
@@ -547,7 +547,7 @@ Updater::processAudioFile( const boost::filesystem::path& file, Stats& stats)
}
catch( std::exception& e )
{
LMS_LOG(MOD_DBUPDATER, SEV_ERROR) << "Exception while parsing audio file : '" << file << "': '" << e.what() << "' => skipping!";
LMS_LOG(DBUPDATER, ERROR) << "Exception while parsing audio file : '" << file << "': '" << e.what() << "' => skipping!";
stats.nbRemoved++;
}
}
@@ -602,7 +602,7 @@ Updater::checkFile(const boost::filesystem::path& p, const std::vector<boost::fi
if (!boost::filesystem::exists( p )
|| !boost::filesystem::is_regular( p ) )
{
LMS_LOG(MOD_DBUPDATER, SEV_INFO) << "Missing file '" << p << "'";
LMS_LOG(DBUPDATER, INFO) << "Missing file '" << p << "'";
status = false;
}
else
@@ -619,12 +619,12 @@ Updater::checkFile(const boost::filesystem::path& p, const std::vector<boost::fi
if (!foundRoot)
{
LMS_LOG(MOD_DBUPDATER, SEV_INFO) << "Out of root file '" << p << "'";
LMS_LOG(DBUPDATER, INFO) << "Out of root file '" << p << "'";
status = false;
}
else if (!isFileSupported(p, extensions))
{
LMS_LOG(MOD_DBUPDATER, SEV_INFO) << "File format no longer supported for '" << p << "'";
LMS_LOG(DBUPDATER, INFO) << "File format no longer supported for '" << p << "'";
status = false;
}
}
@@ -634,7 +634,7 @@ Updater::checkFile(const boost::filesystem::path& p, const std::vector<boost::fi
}
catch (boost::filesystem::filesystem_error& e)
{
LMS_LOG(MOD_DBUPDATER, SEV_ERROR) << "Caught exception while checking file '" << p << "': " << e.what();
LMS_LOG(DBUPDATER, ERROR) << "Caught exception while checking file '" << p << "': " << e.what();
return false;
}
@@ -644,12 +644,12 @@ void
Updater::checkAudioFiles( Stats& stats )
{
LMS_LOG(MOD_DBUPDATER, SEV_INFO) << "Checking audio files...";
LMS_LOG(DBUPDATER, INFO) << "Checking audio files...";
Wt::Dbo::Transaction transaction(_db.getSession());
std::vector<boost::filesystem::path> rootDirs = getRootDirectoriesByType(_db.getSession(), Database::MediaDirectory::Audio);
LMS_LOG(MOD_DBUPDATER, SEV_DEBUG) << "Checking tracks...";
LMS_LOG(DBUPDATER, DEBUG) << "Checking tracks...";
auto tracks = Track::getAll(_db.getSession());
for (auto track : tracks)
{
@@ -661,45 +661,45 @@ Updater::checkAudioFiles( Stats& stats )
}
// Now process orphan Genre (no track)
LMS_LOG(MOD_DBUPDATER, SEV_DEBUG) << "Checking Genres...";
LMS_LOG(DBUPDATER, DEBUG) << "Checking Genres...";
auto genres = Genre::getAll(_db.getSession());
for (auto genre : genres)
{
if (genre->getTracks().size() == 0)
{
LMS_LOG(MOD_DBUPDATER, SEV_DEBUG) << "Removing orphan genre '" << genre->getName() << "'";
LMS_LOG(DBUPDATER, DEBUG) << "Removing orphan genre '" << genre->getName() << "'";
genre.remove();
}
}
LMS_LOG(MOD_DBUPDATER, SEV_DEBUG) << "Checking artists...";
LMS_LOG(DBUPDATER, DEBUG) << "Checking artists...";
auto artists = Artist::getAllOrphans(_db.getSession());
for (auto artist : artists)
{
LMS_LOG(MOD_DBUPDATER, SEV_DEBUG) << "Removing orphan artist '" << artist->getName() << "'";
LMS_LOG(DBUPDATER, DEBUG) << "Removing orphan artist '" << artist->getName() << "'";
artist.remove();
}
LMS_LOG(MOD_DBUPDATER, SEV_DEBUG) << "Checking releases...";
LMS_LOG(DBUPDATER, DEBUG) << "Checking releases...";
auto releases = Release::getAllOrphans(_db.getSession());
for (auto release : releases)
{
LMS_LOG(MOD_DBUPDATER, SEV_DEBUG) << "Removing orphan release '" << release->getName() << "'";
LMS_LOG(DBUPDATER, DEBUG) << "Removing orphan release '" << release->getName() << "'";
release.remove();
}
LMS_LOG(MOD_DBUPDATER, SEV_INFO) << "Check audio files done!";
LMS_LOG(DBUPDATER, INFO) << "Check audio files done!";
}
void
Updater::checkVideoFiles( Stats& stats )
{
LMS_LOG(MOD_DBUPDATER, SEV_DEBUG) << "Checking video files...";
LMS_LOG(DBUPDATER, DEBUG) << "Checking video files...";
Wt::Dbo::Transaction transaction(_db.getSession());
std::vector<boost::filesystem::path> rootDirs = getRootDirectoriesByType(_db.getSession(), Database::MediaDirectory::Video);
LMS_LOG(MOD_DBUPDATER, SEV_DEBUG) << "Checking videos...";
LMS_LOG(DBUPDATER, DEBUG) << "Checking videos...";
typedef Wt::Dbo::collection< Wt::Dbo::ptr<Video> > Videos;
Videos videos = Video::getAll(_db.getSession());
@@ -714,7 +714,7 @@ Updater::checkVideoFiles( Stats& stats )
}
}
LMS_LOG(MOD_DBUPDATER, SEV_DEBUG) << "Check video files done!";
LMS_LOG(DBUPDATER, DEBUG) << "Check video files done!";
}
void
Updater::processVideoFile( const boost::filesystem::path& file, Stats& stats)
@@ -740,7 +740,7 @@ Updater::processVideoFile( const boost::filesystem::path& file, Stats& stats)
if (items.find(MetaData::Type::VideoStreams) == items.end()
|| boost::any_cast<std::vector<MetaData::VideoStream> >(items[MetaData::Type::VideoStreams]).empty())
{
LMS_LOG(MOD_DBUPDATER, SEV_ERROR) << "Skipped '" << file << "' (no video stream found)";
LMS_LOG(DBUPDATER, ERROR) << "Skipped '" << file << "' (no video stream found)";
// If the video exists here, delete it!
if (video) {
@@ -752,7 +752,7 @@ Updater::processVideoFile( const boost::filesystem::path& file, Stats& stats)
if (items.find(MetaData::Type::Duration) == items.end()
|| boost::any_cast<boost::posix_time::time_duration>(items[MetaData::Type::Duration]).total_seconds() == 0)
{
LMS_LOG(MOD_DBUPDATER, SEV_ERROR) << "Skipped '" << file << "' (no duration or duration 0)";
LMS_LOG(DBUPDATER, ERROR) << "Skipped '" << file << "' (no duration or duration 0)";
// If Track exists here, delete it!
if (video) {
@@ -768,12 +768,12 @@ Updater::processVideoFile( const boost::filesystem::path& file, Stats& stats)
if (!video)
{
video = Video::create(_db.getSession(), file);
LMS_LOG(MOD_DBUPDATER, SEV_DEBUG) << "Adding '" << file << "'";
LMS_LOG(DBUPDATER, DEBUG) << "Adding '" << file << "'";
stats.nbAdded++;
}
else
{
LMS_LOG(MOD_DBUPDATER, SEV_DEBUG) << "Updating '" << file << "'";
LMS_LOG(DBUPDATER, DEBUG) << "Updating '" << file << "'";
stats.nbModified++;
}
@@ -787,7 +787,7 @@ Updater::processVideoFile( const boost::filesystem::path& file, Stats& stats)
}
catch( std::exception& e )
{
LMS_LOG(MOD_DBUPDATER, SEV_ERROR) << "Exception while parsing video file : '" << file << "': '" << e.what() << "' => skipping!";
LMS_LOG(DBUPDATER, ERROR) << "Exception while parsing video file : '" << file << "': '" << e.what() << "' => skipping!";
stats.nbScanErrors++;
}
}
+3 -3
View File
@@ -105,7 +105,7 @@ Handler::Handler(Wt::Dbo::SqlConnectionPool& connectionPool)
_session.execute("CREATE INDEX track_name_idx ON track(name)");
}
catch(std::exception& e) {
LMS_LOG(MOD_DB, SEV_ERROR) << "Cannot create tables: " << e.what();
LMS_LOG(DB, ERROR) << "Cannot create tables: " << e.what();
}
_users = new UserDatabase(_session);
@@ -136,7 +136,7 @@ Handler::getUser(const Wt::Auth::User& authUser)
{
if (!authUser.isValid()) {
LMS_LOG(MOD_DB, SEV_ERROR) << "Handler::getUser: invalid authUser";
LMS_LOG(DB, ERROR) << "Handler::getUser: invalid authUser";
return User::pointer();
}
@@ -155,7 +155,7 @@ Handler::getUser(const Wt::Auth::User& authUser)
Wt::Dbo::SqlConnectionPool*
Handler::createConnectionPool(boost::filesystem::path p)
{
LMS_LOG(MOD_DB, SEV_INFO) << "Creating connection pool on file " << p;
LMS_LOG(DB, INFO) << "Creating connection pool on file " << p;
Wt::Dbo::backend::Sqlite3 *connection = new Wt::Dbo::backend::Sqlite3(p.string());
+15 -16
View File
@@ -23,16 +23,16 @@ std::string getModuleName(Module mod)
{
switch (mod)
{
case MOD_AV: return "AV";
case MOD_COVER: return "COVER";
case MOD_DB: return "DB";
case MOD_DBUPDATER: return "DB UPDATER";
case MOD_MAIN: return "MAIN";
case MOD_METADATA: return "METADATA";
case MOD_REMOTE: return "REMOTE";
case MOD_SERVICE: return "SERVICE";
case MOD_TRANSCODE: return "TRANSCODE";
case MOD_UI: return "UI";
case Module::AV: return "AV";
case Module::COVER: return "COVER";
case Module::DB: return "DB";
case Module::DBUPDATER: return "DB UPDATER";
case Module::MAIN: return "MAIN";
case Module::METADATA: return "METADATA";
case Module::REMOTE: return "REMOTE";
case Module::SERVICE: return "SERVICE";
case Module::TRANSCODE: return "TRANSCODE";
case Module::UI: return "UI";
}
return "";
}
@@ -41,12 +41,11 @@ std::string getSeverityName(Severity sev)
{
switch (sev)
{
case SEV_CRIT: return "fatal";
case SEV_ERROR: return "error";
case SEV_WARNING: return "warning";
case SEV_NOTICE:
case SEV_INFO: return "info";
case SEV_DEBUG: return "debug";
case Severity::FATAL: return "fatal";
case Severity::ERROR: return "error";
case Severity::WARNING: return "warning";
case Severity::INFO: return "info";
case Severity::DEBUG: return "debug";
}
return "";
}
+18 -19
View File
@@ -27,33 +27,32 @@
#include <string>
enum Severity
enum class Severity
{
SEV_CRIT = 2,
SEV_ERROR = 3,
SEV_WARNING = 4,
SEV_NOTICE = 5,
SEV_INFO = 6,
SEV_DEBUG = 7,
FATAL,
ERROR,
WARNING,
INFO,
DEBUG,
};
enum Module
enum class Module
{
MOD_AV,
MOD_COVER,
MOD_DB,
MOD_DBUPDATER,
MOD_MAIN,
MOD_METADATA,
MOD_REMOTE,
MOD_SERVICE,
MOD_TRANSCODE,
MOD_UI,
AV,
COVER,
DB,
DBUPDATER,
MAIN,
METADATA,
REMOTE,
SERVICE,
TRANSCODE,
UI,
};
std::string getModuleName(Module mod);
std::string getSeverityName(Severity sev);
#define LMS_LOG(module, level) Wt::log(getSeverityName(level)) << Wt::WLogger::sep << "[" << getModuleName(module) << "]" << Wt::WLogger::sep
#define LMS_LOG(module, level) Wt::log(getSeverityName(Severity::level)) << Wt::WLogger::sep << "[" << getModuleName(Module::module) << "]" << Wt::WLogger::sep
#endif
+8 -8
View File
@@ -68,35 +68,35 @@ int main(int argc, char* argv[])
// bind entry point
server.addEntryPoint(Wt::Application, boost::bind(UserInterface::LmsApplication::create, _1, boost::ref(*connectionPool)));
LMS_LOG(MOD_MAIN, SEV_NOTICE) << "Now running...";
// Starting the main server
LMS_LOG(MOD_MAIN, SEV_INFO) << "Starting server...";
LMS_LOG(MAIN, INFO) << "Starting server...";
server.start();
// Start underlying services
LMS_LOG(MOD_MAIN, SEV_INFO) << "Starting services...";
LMS_LOG(MAIN, INFO) << "Starting services...";
serviceManager.start();
LMS_LOG(MAIN, INFO) << "Now running...";
// Waiting for shutdown command
Wt::WServer::waitForShutdown(argv[0]);
LMS_LOG(MOD_MAIN, SEV_INFO) << "Stopping services...";
LMS_LOG(MAIN, INFO) << "Stopping services...";
serviceManager.stop();
serviceManager.clear();
LMS_LOG(MOD_MAIN, SEV_INFO) << "Stopping server...";
LMS_LOG(MAIN, INFO) << "Stopping server...";
server.stop();
res = EXIT_SUCCESS;
}
catch( Wt::WServer::Exception& e)
{
LMS_LOG(MOD_MAIN, SEV_CRIT) << "Caught a WServer::Exception: " << e.what();
LMS_LOG(MAIN, FATAL) << "Caught a WServer::Exception: " << e.what();
}
catch( std::exception& e)
{
LMS_LOG(MOD_MAIN, SEV_CRIT) << "Caught std::exception: " << e.what();
LMS_LOG(MAIN, FATAL) << "Caught std::exception: " << e.what();
}
return res;
+2 -2
View File
@@ -169,7 +169,7 @@ LmsApplication::handleAuthEvent(void)
{
if (DbHandler().getLogin().loggedIn())
{
LMS_LOG(MOD_UI, SEV_NOTICE) << "User '" << CurrentAuthUser().identity(Wt::Auth::Identity::LoginName) << "' logged in from '" << Wt::WApplication::instance()->environment().clientAddress() << "', user agent = " << Wt::WApplication::instance()->environment().agent() << ", session = " << Wt::WApplication::instance()->sessionId();
LMS_LOG(UI, INFO) << "User '" << CurrentAuthUser().identity(Wt::Auth::Identity::LoginName) << "' logged in from '" << Wt::WApplication::instance()->environment().clientAddress() << "', user agent = " << Wt::WApplication::instance()->environment().agent() << ", session = " << Wt::WApplication::instance()->sessionId();
this->root()->setOverflow(Wt::WContainerWidget::OverflowHidden);
setConfirmCloseMessage("Closing LMS. Are you sure?");
@@ -243,7 +243,7 @@ LmsApplication::handleAuthEvent(void)
}
else
{
LMS_LOG(MOD_UI, SEV_NOTICE) << "User logged out, session = " << Wt::WApplication::instance()->sessionId();
LMS_LOG(UI, INFO) << "User logged out, session = " << Wt::WApplication::instance()->sessionId();
quit("");
redirect("/");
+2 -2
View File
@@ -64,7 +64,7 @@ AudioMediaPlayer::AudioMediaPlayer(Wt::WContainerWidget *parent)
}
}
LMS_LOG(MOD_UI, SEV_INFO) << "Audio player using encoding " << _encoding;
LMS_LOG(UI, INFO) << "Audio player using encoding " << _encoding;
// Current Media info
Wt::WHBoxLayout *currentMediaLayout = new Wt::WHBoxLayout();
@@ -219,7 +219,7 @@ AudioMediaPlayer::load(Database::Track::id_type trackId)
if (!mediaFile.open())
{
// No longer exist ? TODO next?
LMS_LOG(MOD_UI, SEV_INFO) << "Cannot open file '" << path << "'";
LMS_LOG(UI, INFO) << "Cannot open file '" << path << "'";
return;
}
+9 -9
View File
@@ -215,7 +215,7 @@ _playQueue(nullptr)
_mediaPlayer->loop().connect(boost::bind(&PlayQueue::setLoop,_playQueue, _1));
_playQueue->tracksUpdated().connect(std::bind([=] () {
LMS_LOG(MOD_UI, SEV_INFO) << "Playqueue updated!";
LMS_LOG(UI, INFO) << "Playqueue updated!";
playlistSaveFromPlayqueue(CurrentQueuePlaylistName);
}));
@@ -308,14 +308,14 @@ Audio::playlistShowSaveDialog(std::string playlistName)
void
Audio::playlistSaveFromPlayqueue(std::string playlistName)
{
LMS_LOG(MOD_UI, SEV_INFO) << "Saving playqueue to playlist '" << playlistName << "'";
LMS_LOG(UI, INFO) << "Saving playqueue to playlist '" << playlistName << "'";
Wt::Dbo::Transaction transaction(DboSession());
Playlist::pointer playlist = Playlist::get(DboSession(), playlistName, CurrentUser());
if (playlist)
{
LMS_LOG(MOD_UI, SEV_INFO) << "Erasing playlist '" << playlistName << "'";
LMS_LOG(UI, INFO) << "Erasing playlist '" << playlistName << "'";
playlist.remove();
}
@@ -333,13 +333,13 @@ Audio::playlistSaveFromPlayqueue(std::string playlistName)
PlaylistEntry::create(DboSession(), track, playlist, pos++);
}
LMS_LOG(MOD_UI, SEV_INFO) << "Saving playqueue to playlist '" << playlistName << "' done. Contains " << pos << " entries";
LMS_LOG(UI, INFO) << "Saving playqueue to playlist '" << playlistName << "' done. Contains " << pos << " entries";
}
void
Audio::playlistLoadToPlayqueue(std::string playlistName)
{
LMS_LOG(MOD_UI, SEV_DEBUG) << "Loading playlist '" << playlistName << "' to playqueue";
LMS_LOG(UI, DEBUG) << "Loading playlist '" << playlistName << "' to playqueue";
std::vector<Track::id_type> entries;
@@ -356,7 +356,7 @@ Audio::playlistLoadToPlayqueue(std::string playlistName)
_playQueue->clear();
_playQueue->addTracks(entries);
LMS_LOG(MOD_UI, SEV_DEBUG) << "Loading playlist '" << playlistName << "' to playqueue done. " << entries.size() << " entries";
LMS_LOG(UI, DEBUG) << "Loading playlist '" << playlistName << "' to playqueue done. " << entries.size() << " entries";
}
@@ -395,7 +395,7 @@ Audio::playlistRefreshMenus()
Wt::Dbo::Transaction transaction(DboSession());
// Clear playlists in each menu
LMS_LOG(MOD_UI, SEV_DEBUG) << "Save item count: " << _popupMenuSave->count();
LMS_LOG(UI, DEBUG) << "Save item count: " << _popupMenuSave->count();
WPopupMenuClear(_popupMenuDelete);
WPopupMenuClear(_popupMenuLoad);
@@ -457,7 +457,7 @@ Audio::playSelectedTracks(PlayQueueAddType addType)
{
std::vector<Track::id_type> trackIds;
LMS_LOG(MOD_UI, SEV_DEBUG) << "Playing selected tracks... nb selected = " << _trackView->getNbSelectedTracks() << ", add type = " << (addType == PlayQueueAddAllTracks ? "AddAll" : "AddSelected");
LMS_LOG(UI, DEBUG) << "Playing selected tracks... nb selected = " << _trackView->getNbSelectedTracks() << ", add type = " << (addType == PlayQueueAddAllTracks ? "AddAll" : "AddSelected");
_playQueue->clear();
@@ -472,7 +472,7 @@ Audio::playSelectedTracks(PlayQueueAddType addType)
break;
case PlayQueueAddSelectedTracks:
LMS_LOG(MOD_UI, SEV_DEBUG) << "Adding selected tracks...";
LMS_LOG(UI, DEBUG) << "Adding selected tracks...";
// If nothing selected, get all the track and play everything
if (_trackView->getNbSelectedTracks() == 0)
+2 -2
View File
@@ -371,7 +371,7 @@ PlayQueue::addTracks(const std::vector<Database::Track::id_type>& trackIds)
{
using namespace Database;
LMS_LOG(MOD_UI, SEV_DEBUG) << "Adding " << trackIds.size() << " tracks to play queue";
LMS_LOG(UI, DEBUG) << "Adding " << trackIds.size() << " tracks to play queue";
// Add tracks to model
for (Track::id_type trackId : trackIds)
@@ -465,7 +465,7 @@ PlayQueue::playPrevious(void)
void
PlayQueue::readTrack(int rowPos)
{
LMS_LOG(MOD_UI, SEV_DEBUG) << "Reading track at pos " << rowPos << ", row count = " << _model->rowCount();
LMS_LOG(UI, DEBUG) << "Reading track at pos " << rowPos << ", row count = " << _model->rowCount();
if (rowPos < _model->rowCount())
{
+4 -4
View File
@@ -150,7 +150,7 @@ TrackView::refresh(SearchFilter& filter)
void
TrackView::getSelectedTracks(std::vector<Track::id_type>& track_ids)
{
LMS_LOG(MOD_UI, SEV_DEBUG) << "Getting selected tracks...";
LMS_LOG(UI, DEBUG) << "Getting selected tracks...";
Wt::WModelIndexSet indexSet = this->selectedIndexes();
@@ -164,7 +164,7 @@ TrackView::getSelectedTracks(std::vector<Track::id_type>& track_ids)
track_ids.push_back(id);
}
LMS_LOG(MOD_UI, SEV_DEBUG) << "Getting all selected tracks: " << track_ids.size();
LMS_LOG(UI, DEBUG) << "Getting all selected tracks: " << track_ids.size();
}
std::size_t
@@ -192,7 +192,7 @@ TrackView::getFirstSelectedTrackPosition(void)
void
TrackView::getTracks(std::vector<Track::id_type>& trackIds)
{
LMS_LOG(MOD_UI, SEV_DEBUG) << "Getting all tracks...";
LMS_LOG(UI, DEBUG) << "Getting all tracks...";
Wt::Dbo::Transaction transaction(DboSession());
Wt::Dbo::collection<Track::UIQueryResult> results = _queryModel.query();
@@ -203,7 +203,7 @@ TrackView::getTracks(std::vector<Track::id_type>& trackIds)
trackIds.push_back(id);
}
LMS_LOG(MOD_UI, SEV_DEBUG) << "Getting all tracks done! " << trackIds.size() << " tracks!";
LMS_LOG(UI, DEBUG) << "Getting all tracks done! " << trackIds.size() << " tracks!";
}
} // namespace Desktop
+1 -1
View File
@@ -156,7 +156,7 @@ Audio::Audio(Wt::WContainerWidget *parent)
trackSearch->trackPlay().connect(std::bind([=] (Track::id_type id)
{
LMS_LOG(MOD_UI, SEV_DEBUG) << "Playing track id " << id;
LMS_LOG(UI, DEBUG) << "Playing track id " << id;
// TODO reduce transaction scope here
Wt::Dbo::Transaction transaction(DboSession());
@@ -32,12 +32,12 @@ AvConvTranscodeStreamResource::AvConvTranscodeStreamResource(boost::filesystem::
_filePath(p),
_parameters( parameters )
{
LMS_LOG(MOD_UI, SEV_DEBUG) << "CONSTRUCTING RESOURCE";
LMS_LOG(UI, DEBUG) << "CONSTRUCTING RESOURCE";
}
AvConvTranscodeStreamResource::~AvConvTranscodeStreamResource()
{
LMS_LOG(MOD_UI, SEV_DEBUG) << "DESTRUCTING RESOURCE";
LMS_LOG(UI, DEBUG) << "DESTRUCTING RESOURCE";
beingDeleted();
}
@@ -48,7 +48,7 @@ AvConvTranscodeStreamResource::handleRequest(const Wt::Http::Request& request,
// see if this request is for a continuation:
Wt::Http::ResponseContinuation *continuation = request.continuation();
LMS_LOG(MOD_UI, SEV_DEBUG) << "Handling new request. Continuation = " << continuation;
LMS_LOG(UI, DEBUG) << "Handling new request. Continuation = " << continuation;
std::shared_ptr<Av::Transcoder> transcoder;
if (continuation)
@@ -56,15 +56,15 @@ AvConvTranscodeStreamResource::handleRequest(const Wt::Http::Request& request,
if (!transcoder)
{
LMS_LOG(MOD_UI, SEV_DEBUG) << "Launching transcoder";
LMS_LOG(UI, DEBUG) << "Launching transcoder";
transcoder = std::make_shared<Av::Transcoder>( _filePath, _parameters);
LMS_LOG(MOD_UI, SEV_DEBUG) << "Mime type set to '" << Av::encoding_to_mimetype(_parameters.getEncoding());
LMS_LOG(UI, DEBUG) << "Mime type set to '" << Av::encoding_to_mimetype(_parameters.getEncoding());
response.setMimeType( Av::encoding_to_mimetype(_parameters.getEncoding()) );
if (!transcoder->start())
{
LMS_LOG(MOD_UI, SEV_ERROR) << "Cannot start transcoder";
LMS_LOG(UI, ERROR) << "Cannot start transcoder";
return;
}
}
@@ -79,10 +79,10 @@ AvConvTranscodeStreamResource::handleRequest(const Wt::Http::Request& request,
// Give the client all the output data
response.out().write(reinterpret_cast<char*>(&data[0]), data.size());
LMS_LOG(MOD_UI, SEV_DEBUG) << "Written " << data.size() << " bytes! complete = " << std::boolalpha << transcoder->isComplete();
LMS_LOG(UI, DEBUG) << "Written " << data.size() << " bytes! complete = " << std::boolalpha << transcoder->isComplete();
if (!response.out())
LMS_LOG(MOD_UI, SEV_ERROR) << "Write failed!";
LMS_LOG(UI, ERROR) << "Write failed!";
}
if (!transcoder->isComplete() && response.out()) {
@@ -90,7 +90,7 @@ AvConvTranscodeStreamResource::handleRequest(const Wt::Http::Request& request,
continuation->setData(transcoder);
}
else
LMS_LOG(MOD_UI, SEV_DEBUG) << "No more data!";
LMS_LOG(UI, DEBUG) << "No more data!";
}
} // namespace UserInterface
+1 -1
View File
@@ -175,7 +175,7 @@ CoverResource::handleRequest(const Wt::Http::Request& request, Wt::Http::Respons
}
catch (std::invalid_argument& e)
{
LMS_LOG(MOD_UI, SEV_ERROR) << "Invalid argument: " << e.what();
LMS_LOG(UI, ERROR) << "Invalid argument: " << e.what();
}
}
+1 -1
View File
@@ -91,7 +91,7 @@ Settings::Settings(Wt::WContainerWidget* parent)
void
Settings::handleDatabaseDirectoriesChanged()
{
LMS_LOG(MOD_UI, SEV_NOTICE) << "Media directories have changed: requesting imediate scan";
LMS_LOG(UI, INFO) << "Media directories have changed: requesting imediate scan";
// On directory add or delete, request an immediate scan
{
Wt::Dbo::Transaction transaction(DboSession());
+1 -1
View File
@@ -116,7 +116,7 @@ class AccountFormModel : public Wt::WFormModel
}
catch(Wt::Dbo::Exception& exception)
{
LMS_LOG(MOD_UI, SEV_ERROR) << "Dbo exception: " << exception.what();
LMS_LOG(UI, ERROR) << "Dbo exception: " << exception.what();
return false;
}
+1 -1
View File
@@ -100,7 +100,7 @@ class AudioFormModel : public Wt::WFormModel
}
catch(Wt::Dbo::Exception& exception)
{
LMS_LOG(MOD_UI, SEV_ERROR) << "Dbo exception: " << exception.what();
LMS_LOG(UI, ERROR) << "Dbo exception: " << exception.what();
return false;
}
+1 -1
View File
@@ -106,7 +106,7 @@ class DatabaseFormModel : public Wt::WFormModel
}
catch(Wt::Dbo::Exception& exception)
{
LMS_LOG(MOD_UI, SEV_ERROR) << "Dbo exception: " << exception.what();
LMS_LOG(UI, ERROR) << "Dbo exception: " << exception.what();
return false;
}
@@ -67,7 +67,7 @@ class FirstConnectionFormModel : public Wt::WFormModel
// If it's the case, just do nothing
if (!Database::User::getAll(DboSession()).empty())
{
LMS_LOG(MOD_UI, SEV_ERROR) << "Admin user already created";
LMS_LOG(UI, ERROR) << "Admin user already created";
error = Wt::WString("Admin user already created!");
return false;
}
@@ -86,7 +86,7 @@ class FirstConnectionFormModel : public Wt::WFormModel
}
catch(Wt::Dbo::Exception& exception)
{
LMS_LOG(MOD_UI, SEV_ERROR) << "Dbo exception: " << exception.what();
LMS_LOG(UI, ERROR) << "Dbo exception: " << exception.what();
error = Wt::WString(exception.what());
return false;
}
@@ -81,7 +81,7 @@ class MediaDirectoryFormModel : public Wt::WFormModel
}
catch(Wt::Dbo::Exception& exception)
{
LMS_LOG(MOD_UI, SEV_ERROR) << "Dbo exception: " << exception.what();
LMS_LOG(UI, ERROR) << "Dbo exception: " << exception.what();
return false;
}
+3 -3
View File
@@ -168,12 +168,12 @@ class UserFormModel : public Wt::WFormModel
// user may have been deleted by someone else
if (!authUser.isValid()) {
LMS_LOG(MOD_UI, SEV_ERROR) << "user identity does not exist!";
LMS_LOG(UI, ERROR) << "user identity does not exist!";
return false;
}
else if(!user)
{
LMS_LOG(MOD_UI, SEV_ERROR) << "User not found!";
LMS_LOG(UI, ERROR) << "User not found!";
return false;
}
@@ -206,7 +206,7 @@ class UserFormModel : public Wt::WFormModel
}
catch(Wt::Dbo::Exception& exception)
{
LMS_LOG(MOD_UI, SEV_ERROR) << "Dbo exception: " << exception.what();
LMS_LOG(UI, ERROR) << "Dbo exception: " << exception.what();
return false;
}
+2 -2
View File
@@ -96,12 +96,12 @@ Users::refresh(void)
}
catch(Wt::Dbo::Exception& e)
{
LMS_LOG(MOD_UI, SEV_ERROR) << "Caught exception when getting userId=" << userId << ": " << e.code();
LMS_LOG(UI, ERROR) << "Caught exception when getting userId=" << userId << ": " << e.code();
continue;
}
if (!authUser.isValid()) {
LMS_LOG(MOD_UI, SEV_ERROR) << "Users::refresh: skipping invalid userId = " << userId;
LMS_LOG(UI, ERROR) << "Users::refresh: skipping invalid userId = " << userId;
continue;
}