diff --git a/av/Codec.cpp b/av/Codec.cpp index 3756b78e..59cf0a1f 100644 --- a/av/Codec.cpp +++ b/av/Codec.cpp @@ -2,6 +2,8 @@ #include #include +#include "logger/Logger.hpp" + #include "Codec.hpp" Codec::Codec(enum CodecID codec, Type type ) @@ -13,7 +15,7 @@ Codec::Codec(enum CodecID codec, Type type ) _codec = avcodec_find_decoder(codec); if (_codec == nullptr) { - std::cerr << "Codec constructor failed! codec = " << codec << ", type = " << type << std::endl; + LMS_LOG(MOD_AV, SEV_ERROR) << "Codec constructor failed! codec = " << codec << ", type = " << type; throw std::runtime_error("can't find codec using this id!"); } } diff --git a/av/Common.cpp b/av/Common.cpp index a35e18cb..827efbee 100644 --- a/av/Common.cpp +++ b/av/Common.cpp @@ -1,7 +1,9 @@ -#include "Common.hpp" - #include +#include "logger/Logger.hpp" + +#include "Common.hpp" + namespace Av { @@ -28,7 +30,7 @@ void AvInit() /* register all the codecs */ avcodec_register_all(); av_register_all(); - std::cout << "AVCDOEC VERSION = " << avcodec_version() << std::endl; + LMS_LOG(MOD_AV, SEV_INFO) << "AVCDOEC VERSION = " << avcodec_version(); } } // namespace Av diff --git a/av/InputFormatContext.cpp b/av/InputFormatContext.cpp index 4a5fc897..a901e948 100644 --- a/av/InputFormatContext.cpp +++ b/av/InputFormatContext.cpp @@ -1,6 +1,8 @@ #include #include +#include "logger/Logger.hpp" + #include "InputFormatContext.hpp" namespace Av @@ -17,7 +19,7 @@ InputFormatContext::InputFormatContext(const boost::filesystem::path& p) AvError error = avformat_open_input(&context, p.string().c_str(), nullptr, nullptr); if (error) { - std::cerr << "Cannot open '" << p.string() << "', avformat_open_input returned " << error << std::endl; + LMS_LOG(MOD_AV, SEV_ERROR) << "Cannot open '" << p.string() << "', avformat_open_input returned " << error; throw std::runtime_error("avformat_open_input failed: " + error.to_str()); } @@ -57,7 +59,7 @@ InputFormatContext::getBestStreamIdx(AVMediaType type, Stream::Idx& index) AvError error(res); if (error) { - std::cerr << "Cannot get best stream for type " << type << ": " << error << std::endl; + LMS_LOG(MOD_AV, SEV_DEBUG) << "Cannot get best stream for type " << type << ": " << error; return false; } else { @@ -72,7 +74,7 @@ InputFormatContext::findStreamInfo(void) native()->max_analyze_duration = 10 * AV_TIME_BASE; // 10 secs AvError err = avformat_find_stream_info(native(), NULL); if (err) { - std::cerr << "Couldn't find stream information: " << err << std::endl; + LMS_LOG(MOD_AV, SEV_ERROR) << "Couldn't find stream information: " << err; throw std::runtime_error("av_find_stream_info failed!"); } } diff --git a/cover/CoverArt.cpp b/cover/CoverArt.cpp index 353b1b47..0be8568d 100644 --- a/cover/CoverArt.cpp +++ b/cover/CoverArt.cpp @@ -5,6 +5,8 @@ #include #include +#include "logger/Logger.hpp" + #include "CoverArt.hpp" namespace CoverArt { @@ -46,7 +48,7 @@ CoverArt::scale(std::size_t size) } catch(std::exception& e) { - std::cerr << "Caught exception: " << e.what() << std::endl; + LMS_LOG(MOD_COVER, SEV_ERROR) << "Caught exception: " << e.what(); } return res; diff --git a/cover/CoverArtGrabber.cpp b/cover/CoverArtGrabber.cpp index 788648c6..e94cb375 100644 --- a/cover/CoverArtGrabber.cpp +++ b/cover/CoverArtGrabber.cpp @@ -1,9 +1,11 @@ #include +#include "logger/Logger.hpp" +#include "av/InputFormatContext.hpp" + #include "CoverArtGrabber.hpp" -#include "av/InputFormatContext.hpp" namespace CoverArt { @@ -25,7 +27,7 @@ Grabber::getFromInputFormatContext(const Av::InputFormatContext& input) } catch(std::exception& e) { - std::cerr << "Cannot get pictures: " << e.what() << std::endl; + LMS_LOG(MOD_COVER, SEV_ERROR) << "Cannot get pictures: " << e.what(); } return res; @@ -50,7 +52,7 @@ Grabber::getFromTrack(Database::Track::pointer track) } catch(std::exception& e) { - std::cerr << "Cannot get pictures: " << e.what(); + LMS_LOG(MOD_COVER, SEV_ERROR) << "Cannot get pictures: " << e.what(); } return res; diff --git a/database-updater/Checksum.cpp b/database-updater/Checksum.cpp index 9bd704e6..44179857 100644 --- a/database-updater/Checksum.cpp +++ b/database-updater/Checksum.cpp @@ -3,6 +3,8 @@ #include // for boost::crc_32_type +#include "logger/Logger.hpp" + #include "Checksum.hpp" typedef boost::crc_32_type crc_type; @@ -26,7 +28,7 @@ void computeCrc(const boost::filesystem::path& p, std::vector& cr } else { - std::cerr << "Failed to open file '" << p << "'" << std::endl; + LMS_LOG(MOD_DBUPDATER, SEV_ERROR) << "Failed to open file '" << p << "'"; throw std::runtime_error("Failed to open file '" + p.string() + "'" ); } diff --git a/database-updater/DatabaseUpdater.cpp b/database-updater/DatabaseUpdater.cpp index b4f6b7d3..fc141082 100644 --- a/database-updater/DatabaseUpdater.cpp +++ b/database-updater/DatabaseUpdater.cpp @@ -4,6 +4,8 @@ #include #include +#include "logger/Logger.hpp" + #include "database/MediaDirectory.hpp" #include "database/AudioTypes.hpp" @@ -109,7 +111,7 @@ Updater::processNextJob(void) MediaDirectorySettings::pointer settings = MediaDirectorySettings::get(_db.getSession()); if (settings->getManualScanRequested()) { - std::cout << "Manual scan requested!" << std::endl; + LMS_LOG(MOD_DBUPDATER, SEV_NOTICE) << "Manual scan requested!"; scheduleScan( boost::posix_time::seconds(0) ); } else @@ -152,7 +154,7 @@ Updater::processNextJob(void) void Updater::scheduleScan( boost::posix_time::time_duration duration) { - std::cout << "Scheduling next scan in " << duration << std::endl; + LMS_LOG(MOD_DBUPDATER, SEV_NOTICE) << "Scheduling next scan in " << duration; _scheduleTimer.expires_from_now(duration); _scheduleTimer.async_wait( boost::bind( &Updater::process, this, boost::asio::placeholders::error) ); } @@ -160,7 +162,7 @@ Updater::scheduleScan( boost::posix_time::time_duration duration) void Updater::scheduleScan( boost::posix_time::ptime time) { - std::cout << "Scheduling next scan at " << time << std::endl; + LMS_LOG(MOD_DBUPDATER, SEV_NOTICE) << "Scheduling next scan at " << time; _scheduleTimer.expires_at(time); _scheduleTimer.async_wait( boost::bind( &Updater::process, this, boost::asio::placeholders::error) ); } @@ -188,7 +190,7 @@ Updater::process(boost::system::error_code err) BOOST_FOREACH( RootDirectory rootDirectory, rootDirectories) processDirectory(rootDirectory.first, rootDirectory.first, rootDirectory.second, stats); - std::cout << "Changes = " << stats.nbChanges() << std::endl; + LMS_LOG(MOD_DBUPDATER, SEV_INFO) << "Changes = " << stats.nbChanges(); // Update database stats boost::posix_time::ptime now = boost::posix_time::second_clock::local_time(); @@ -240,7 +242,7 @@ Updater::processAudioFile( const boost::filesystem::path& file, Stats& stats) if (items.find(MetaData::AudioStreams) == items.end() || boost::any_cast >(items[MetaData::AudioStreams]).empty()) { - std::cerr << "Skipped '" << file << "' (no audio stream found)" << std::endl; + LMS_LOG(MOD_DBUPDATER, SEV_DEBUG) << "Skipped '" << file << "' (no audio stream found)"; // If Track exists here, delete it! if (track) { @@ -252,7 +254,7 @@ Updater::processAudioFile( const boost::filesystem::path& file, Stats& stats) if (items.find(MetaData::Duration) == items.end() || boost::any_cast(items[MetaData::Duration]).total_seconds() == 0) { - std::cerr << "Skipped '" << file << "' (no duration or duration 0)" << std::endl; + LMS_LOG(MOD_DBUPDATER, SEV_DEBUG) << "Skipped '" << file << "' (no duration or duration 0)"; // If Track exists here, delete it! if (track) { @@ -330,12 +332,12 @@ Updater::processAudioFile( const boost::filesystem::path& file, Stats& stats) { // Create a new song track = Track::create(_db.getSession(), file, artist, release); - std::cout << "Adding '" << file << "'" << std::endl; + LMS_LOG(MOD_DBUPDATER, SEV_INFO) << "Adding '" << file << "'"; stats.nbAdded++; } else { - std::cout << "Updating '" << file << "'" << std::endl; + LMS_LOG(MOD_DBUPDATER, SEV_INFO) << "Updating '" << file << "'"; stats.nbModified++; } @@ -375,7 +377,7 @@ Updater::processAudioFile( const boost::filesystem::path& file, Stats& stats) } catch( std::exception& e ) { - std::cerr << "Exception while parsing audio file : '" << file << "': '" << e.what() << "' => skipping!" << std::endl; + LMS_LOG(MOD_DBUPDATER, SEV_ERROR) << "Exception while parsing audio file : '" << file << "': '" << e.what() << "' => skipping!"; } } @@ -427,7 +429,7 @@ Updater::checkFile(const boost::filesystem::path& p, const std::vector rootDirs = getRootDirectoriesByType(_db.getSession(), Database::MediaDirectory::Audio); - std::cerr << "Checking tracks..." << std::endl; + LMS_LOG(MOD_DBUPDATER, SEV_DEBUG) << "Checking tracks..."; typedef Wt::Dbo::collection< Wt::Dbo::ptr > Tracks; Tracks tracks = Track::getAll(_db.getSession()); @@ -477,29 +479,30 @@ Updater::checkAudioFiles( Stats& stats ) } } - std::cerr << "Checking Artists..." << std::endl; + LMS_LOG(MOD_DBUPDATER, SEV_DEBUG) << "Checking Artists..."; // Now process orphan Artists (no track) typedef Wt::Dbo::collection< Wt::Dbo::ptr > Artists; Artists artists = Artist::getAllOrphans(_db.getSession()); for (Artists::iterator it = artists.begin(); it != artists.end(); ++it) { - std::cout << "Removing orphan artist " << (*it)->getName() << std::endl; + LMS_LOG(MOD_DBUPDATER, SEV_INFO) << "Removing orphan artist " << (*it)->getName(); (*it).remove(); } - std::cerr << "Checking Releases..." << std::endl; + LMS_LOG(MOD_DBUPDATER, SEV_DEBUG) << "Checking Releases..."; // Now process orphan Release (no track) typedef Wt::Dbo::collection< Wt::Dbo::ptr > Releases; Releases releases = Release::getAllOrphans(_db.getSession()); for (Releases::iterator it = releases.begin(); it != releases.end(); ++it) { - std::cout << "Removing orphan release " << (*it)->getName() << std::endl; + LMS_LOG(MOD_DBUPDATER, SEV_INFO) << "Removing orphan release " << (*it)->getName(); (*it).remove(); } - std::cerr << "Checking Genres..." << std::endl; + // Now process orphan Genre (no track) + LMS_LOG(MOD_DBUPDATER, SEV_DEBUG) << "Checking Genres..."; typedef Wt::Dbo::collection< Wt::Dbo::ptr > Genres; Genres genres = Genre::getAll(_db.getSession()); @@ -511,9 +514,8 @@ Updater::checkAudioFiles( Stats& stats ) genre.remove(); } - // Now process orphan Genre (no track) - std::cerr << "Check audio files done!" << std::endl; + LMS_LOG(MOD_DBUPDATER, SEV_DEBUG) << "Check audio files done!"; } Path::pointer @@ -542,7 +544,7 @@ Updater::getAddPath(const boost::filesystem::path& path) /*void Updater::refreshVideoDirectory( const boost::filesystem::path& path) { - std::cout << "Refreshing video directory " << path << std::endl; + LMS_LOG(MOD_DBUPDATER, SEV_DEBUG) << "Refreshing video directory " << path; if (boost::filesystem::exists(path) && boost::filesystem::is_directory(path)) { @@ -571,11 +573,11 @@ Updater::refreshVideoDirectory( const boost::filesystem::path& path) processVideoFile( pathChild ); } else { - std::cout << "Skipped '" << pathChild << "' (not regular)" << std::endl; + LMS_LOG(MOD_DBUPDATER, SEV_DEBUG) << "Skipped '" << pathChild << "' (not regular)"; } } } - std::cout << "Refreshing video directory " << path << ": DONE" << std::endl; + LMS_LOG(MOD_DBUPDATER, SEV_DEBUG) << "Refreshing video directory " << path << ": DONE"; }*/ /* void @@ -592,12 +594,12 @@ Updater::processVideoFile( const boost::filesystem::path& file) Path::pointer dbPath = Path::getByPath(_db.getSession(), file); if (dbPath && dbPath->getLastWriteTime() == lastWriteTime) { - std::cerr << "Skipped '" << file << "' (last write time match)" << std::endl; + LMS_LOG(MOD_DBUPDATER, SEV_ERROR) << "Skipped '" << file << "' (last write time match)"; return; } - std::cout << "Video, parsing file " << file << std::endl; + LMS_LOG(MOD_DBUPDATER, SEV_DEBUG) << "Video, parsing file " << file; MetaData::Items items; _metadataParser.parse(file, items); @@ -608,7 +610,7 @@ Updater::processVideoFile( const boost::filesystem::path& file) if (items.find(MetaData::VideoStreams) == items.end() || boost::any_cast >(items[MetaData::VideoStreams]).empty()) { - std::cerr << "Skipped '" << file << "' (no video stream found)" << std::endl; + LMS_LOG(MOD_DBUPDATER, SEV_ERROR) << "Skipped '" << file << "' (no video stream found)"; // If Track exists here, delete it! if (dbPath) @@ -617,7 +619,7 @@ Updater::processVideoFile( const boost::filesystem::path& file) else if (items.find(MetaData::Duration) == items.end() || boost::any_cast(items[MetaData::Duration]).total_seconds() == 0) { - std::cerr << "Skipped '" << file << "' (no duration or duration 0)" << std::endl; + LMS_LOG(MOD_DBUPDATER, SEV_ERROR) << "Skipped '" << file << "' (no duration or duration 0)"; // If Track exists here, delete it! if (dbPath) @@ -639,10 +641,10 @@ Updater::processVideoFile( const boost::filesystem::path& file) Video::pointer video = dbPath.modify()->getVideo(); if (!video) { video = Video::create(_db.getSession(), dbPath); - std::cout << "Adding '" << file << "'" << std::endl; + LMS_LOG(MOD_DBUPDATER, SEV_DEBUG) << "Adding '" << file << "'"; } else - std::cout << "Updating '" << file << "'" << std::endl; + LMS_LOG(MOD_DBUPDATER, SEV_DEBUG) << "Updating '" << file << "'"; assert(video); @@ -653,7 +655,7 @@ Updater::processVideoFile( const boost::filesystem::path& file) transaction.commit(); } catch( std::exception& e ) { - std::cerr << "Exception while parsing video file : '" << file << "': '" << e.what() << "' => skipping!" << std::endl; + LMS_LOG(MOD_DBUPDATER, SEV_ERROR) << "Exception while parsing video file : '" << file << "': '" << e.what() << "' => skipping!"; } } */ diff --git a/database/DatabaseHandler.cpp b/database/DatabaseHandler.cpp index d6bf283a..830bd9b7 100644 --- a/database/DatabaseHandler.cpp +++ b/database/DatabaseHandler.cpp @@ -6,6 +6,8 @@ #include #include +#include "logger/Logger.hpp" + // Db types #include "AudioTypes.hpp" #include "FileTypes.hpp" @@ -79,7 +81,7 @@ _dbBackend( db.string() ) _session.createTables(); } catch(std::exception& e) { - std::cerr << "Cannot create tables: " << e.what() << std::endl; + LMS_LOG(MOD_DB, SEV_ERROR) << "Cannot create tables: " << e.what(); } _dbBackend.executeSql("pragma journal_mode=WAL"); @@ -112,7 +114,7 @@ Handler::getUser(const Wt::Auth::User& authUser) { if (!authUser.isValid()) { - std::cerr << "Handler::getUser: invalid authUser" << std::endl; + LMS_LOG(MOD_DB, SEV_ERROR) << "Handler::getUser: invalid authUser"; return User::pointer(); } diff --git a/logger/Logger.cpp b/logger/Logger.cpp index 12b6e6dc..1cafd76d 100644 --- a/logger/Logger.cpp +++ b/logger/Logger.cpp @@ -14,6 +14,7 @@ #include #include #include +#include #include @@ -30,21 +31,31 @@ Logger::instance() Logger::Logger() { // Initialiaz loggers - static const struct LoggerDef { - Module module; - std::string name; - } loggers[] = { - {MOD_MAIN, "MAIN"}, - {MOD_UI, "UI"}, - {MOD_REMOTE, "REMOTE"} + static const std::vector modules = + { + MOD_AV, + MOD_COVER, + MOD_DB, + MOD_DBUPDATER, + MOD_MAIN, + MOD_METADATA, + MOD_REMOTE, + MOD_SERVICE, + MOD_TRANSCODE, + MOD_UI, }; - BOOST_FOREACH(const struct LoggerDef& logger, loggers) { - std::cout << "Adding attribute" << std::endl; - _loggers[logger.module].add_attribute("Module", boost::log::attributes::constant< Module >(logger.module)); - } + BOOST_FOREACH(Module module, modules) + _loggers[module].add_attribute("Module", boost::log::attributes::constant< Module >(module)); } +boost::log::sources::severity_logger< Severity >& +Logger::get(Module module) +{ + return _loggers[module]; +} + + void Logger::init(const Config& config) { diff --git a/logger/Logger.hpp b/logger/Logger.hpp index 4a06c2bd..6916055b 100644 --- a/logger/Logger.hpp +++ b/logger/Logger.hpp @@ -7,25 +7,32 @@ #include #include -#include +#include #define LMS_LOG(module, level) BOOST_LOG_SEV(Logger::instance().get(module), level) enum Severity { - SEV_DEBUG = 7, - SEV_INFO = 6, - SEV_NOTICE = 5, - SEV_WARNING = 4, - SEV_ERROR = 3, SEV_CRIT = 2, + SEV_ERROR = 3, + SEV_WARNING = 4, + SEV_NOTICE = 5, + SEV_INFO = 6, + SEV_DEBUG = 7, }; enum Module { - MOD_MAIN = 0, - MOD_UI, + MOD_AV = 0, + MOD_COVER, + MOD_DB, + MOD_DBUPDATER, + MOD_MAIN, + MOD_METADATA, MOD_REMOTE, + MOD_SERVICE, + MOD_TRANSCODE, + MOD_UI, }; BOOST_LOG_ATTRIBUTE_KEYWORD(module, "Module", Module) @@ -47,7 +54,7 @@ class Logger void init(const Config& config); boost::log::sources::severity_logger< Severity >& - get(Module module) { return _loggers[module]; } + get(Module module); private: @@ -83,14 +90,24 @@ template< typename CharT, typename TraitsT > inline std::basic_ostream< CharT, TraitsT >& operator<< ( std::basic_ostream< CharT, TraitsT >& strm, Module val) { - static const char* const str[] = + const char* res = NULL; + + switch(val) { - "MAIN", - "UI", - "REMOTE", - }; - if (static_cast< std::size_t >(val) < (sizeof(str) / sizeof(*str))) - strm << str[val]; + case MOD_AV: res = "AV"; break; + case MOD_COVER: res = "COVER"; break; + case MOD_DB: res = "DB"; break; + case MOD_DBUPDATER: res = "DBUPDATER"; break; + case MOD_MAIN: res = "MAIN"; break; + case MOD_METADATA: res = "METADATA"; break; + case MOD_REMOTE: res = "REMOTE"; break; + case MOD_SERVICE: res = "SERVICE"; break; + case MOD_TRANSCODE: res = "TRANSCODE"; break; + case MOD_UI: res = "UI"; break; + } + + if (res) + strm << res; else strm << static_cast< int >(val); return strm; diff --git a/main/main.cpp b/main/main.cpp index a5c606d7..26dfc1e8 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -48,6 +48,7 @@ int main(int argc, char* argv[]) Logger::instance().init(loggerConfig); } + LMS_LOG(MOD_MAIN, SEV_INFO) << "Reading service configurations..."; Service::DatabaseUpdateService::Config dbUpdateConfig; configReader.getDatabaseUpdateConfig(dbUpdateConfig); @@ -65,7 +66,7 @@ int main(int argc, char* argv[]) Transcode::AvConvTranscoder::init(); Database::Handler::configureAuth(); - std::cout << "Starting services..." << std::endl; + LMS_LOG(MOD_MAIN, SEV_INFO) << "Starting services..."; if (dbUpdateConfig.enable) serviceManager.startService( std::make_shared( dbUpdateConfig ) ); @@ -76,7 +77,7 @@ int main(int argc, char* argv[]) if (uiConfig.enable) serviceManager.startService( std::make_shared(boost::filesystem::path(argv[0]), uiConfig)); - std::cout << "Running..." << std::endl; + LMS_LOG(MOD_MAIN, SEV_NOTICE) << "Now running..."; serviceManager.run(); @@ -89,11 +90,11 @@ int main(int argc, char* argv[]) } catch( Wt::WServer::Exception& e) { - std::cerr << "Caught WServer::Exception: " << e.what() << std::endl; + LMS_LOG(MOD_MAIN, SEV_CRIT) << "Caught a WServer::Exception: " << e.what(); } catch( std::exception& e) { - std::cerr << "Caught std::exception: " << e.what() << std::endl; + LMS_LOG(MOD_MAIN, SEV_CRIT) << "Caught std::exception: " << e.what(); } return res; diff --git a/metadata/AvFormat.cpp b/metadata/AvFormat.cpp index 00c28b31..d8f9139b 100644 --- a/metadata/AvFormat.cpp +++ b/metadata/AvFormat.cpp @@ -6,6 +6,8 @@ #include "av/InputFormatContext.hpp" +#include "logger/Logger.hpp" + #include "Utils.hpp" namespace MetaData @@ -134,17 +136,16 @@ AvFormat::parse(const boost::filesystem::path& p, Items& items) } /* else - std::cout << "key = " << it->first << ", value = " << it->second << std::endl; + LMS_LOG(MOD_METADATA, SEV_DEBUG) << "key = " << it->first << ", value = " << it->second; */ } } catch(std::exception &e) { - std::cerr << "Parsing of '" << p << "' failed!" << std::endl; + LMS_LOG(MOD_METADATA, SEV_ERROR) << "Parsing of '" << p << "' failed!"; } - } } // namespace MetaData diff --git a/remote/messages/Header.hpp b/remote/messages/Header.hpp index 4c909012..0f56c19e 100644 --- a/remote/messages/Header.hpp +++ b/remote/messages/Header.hpp @@ -1,6 +1,8 @@ #ifndef REMOTE_HEADER_HPP #define REMOTE_HEADER_HPP +#include "logger/Logger.hpp" + #include namespace Remote @@ -33,7 +35,7 @@ class Header bool from_buffer(const std::array& buffer) { if (decode32(&buffer[0]) != _magic) { - std::cerr << "Header: bad magic ('" << std::hex << std::setfill('0') << std::setw(8) << decode32(&buffer[0]) << "' instead of '" << std::hex << std::setfill('0') << std::setw(8) << _magic << "')" << std::endl; + LMS_LOG(MOD_REMOTE, SEV_ERROR) << "Header: bad magic ('" << std::hex << std::setfill('0') << std::setw(8) << decode32(&buffer[0]) << "' instead of '" << std::hex << std::setfill('0') << std::setw(8) << _magic << "')"; return false; } else @@ -41,7 +43,7 @@ class Header _dataSize = decode32(&buffer[4]); if (_dataSize > max_data_size) - std::cerr << "Header: msg too big (" << _dataSize << ")!" << std::endl; + LMS_LOG(MOD_REMOTE, SEV_ERROR) << "Header: msg too big (" << _dataSize << ")!"; return _dataSize <= max_data_size; } diff --git a/remote/server/AudioCollectionRequestHandler.cpp b/remote/server/AudioCollectionRequestHandler.cpp index e8d7927c..be1a71a2 100644 --- a/remote/server/AudioCollectionRequestHandler.cpp +++ b/remote/server/AudioCollectionRequestHandler.cpp @@ -4,6 +4,8 @@ #include #include +#include "logger/Logger.hpp" + #include "AudioCollectionRequestHandler.hpp" #include "database/AudioTypes.hpp" @@ -34,7 +36,7 @@ AudioCollectionRequestHandler::process(const AudioCollectionRequest& request, Au response.set_type(AudioCollectionResponse::TypeRevision); } else - std::cerr << "Bad AudioCollectionRequest::TypeGetRevision" << std::endl; + LMS_LOG(MOD_REMOTE, SEV_ERROR) << "Bad AudioCollectionRequest::TypeGetRevision"; break; case AudioCollectionRequest::TypeGetGenreList: @@ -45,7 +47,7 @@ AudioCollectionRequestHandler::process(const AudioCollectionRequest& request, Au response.set_type(AudioCollectionResponse::TypeArtistList); } else - std::cerr << "Bad AudioCollectionRequest::TypeGetGenreList" << std::endl; + LMS_LOG(MOD_REMOTE, SEV_ERROR) << "Bad AudioCollectionRequest::TypeGetGenreList"; break; case AudioCollectionRequest::TypeGetArtistList: @@ -57,7 +59,7 @@ AudioCollectionRequestHandler::process(const AudioCollectionRequest& request, Au } else - std::cerr << "Bad AudioCollectionRequest::TypeGetArtistList message!" << std::endl; + LMS_LOG(MOD_REMOTE, SEV_ERROR) << "Bad AudioCollectionRequest::TypeGetArtistList message!"; break; case AudioCollectionRequest::TypeGetReleaseList: @@ -69,7 +71,7 @@ AudioCollectionRequestHandler::process(const AudioCollectionRequest& request, Au } else - std::cerr << "Bad AudioCollectionRequest::TypeGetReleaseList message!" << std::endl; + LMS_LOG(MOD_REMOTE, SEV_ERROR) << "Bad AudioCollectionRequest::TypeGetReleaseList message!"; break; case AudioCollectionRequest::TypeGetTrackList: @@ -81,18 +83,18 @@ AudioCollectionRequestHandler::process(const AudioCollectionRequest& request, Au } else - std::cerr << "Bad AudioCollectionRequest::TypeGetTrackList message!" << std::endl; + LMS_LOG(MOD_REMOTE, SEV_ERROR) << "Bad AudioCollectionRequest::TypeGetTrackList message!"; break; case AudioCollectionRequest::TypeGetCoverArt: if (request.has_get_cover_art()) res = processGetCoverArt(request.get_cover_art(), response); else - std::cerr << "Bad AudioCollectionRequest::TypeGetCoverArt message!" << std::endl; + LMS_LOG(MOD_REMOTE, SEV_ERROR) << "Bad AudioCollectionRequest::TypeGetCoverArt message!"; break; default: - std::cerr << "Unhandled AudioCollectionRequest_Type = " << request.type() << std::endl; + LMS_LOG(MOD_REMOTE, SEV_ERROR) << "Unhandled AudioCollectionRequest_Type = " << request.type(); } @@ -106,7 +108,7 @@ AudioCollectionRequestHandler::processGetGenres(const AudioCollectionRequest::Ge // sanity checks if (!request.has_batch_parameter()) { - std::cerr << "No batch parameters found!" << std::endl; + LMS_LOG(MOD_REMOTE, SEV_ERROR) << "No batch parameters found!"; return false; } @@ -138,7 +140,7 @@ AudioCollectionRequestHandler::processGetArtists(const AudioCollectionRequest::G // sanity checks if (!request.has_batch_parameter()) { - std::cerr << "No batch parameters found!" << std::endl; + LMS_LOG(MOD_REMOTE, SEV_ERROR) << "No batch parameters found!"; return false; } @@ -172,7 +174,7 @@ AudioCollectionRequestHandler::processGetReleases(const AudioCollectionRequest:: // sanity checks if (!request.has_batch_parameter()) { - std::cerr << "No batch parameters found!" << std::endl; + LMS_LOG(MOD_REMOTE, SEV_ERROR) << "No batch parameters found!"; return false; } @@ -208,7 +210,7 @@ AudioCollectionRequestHandler::processGetTracks(const AudioCollectionRequest::Ge // sanity checks if (!request.has_batch_parameter()) { - std::cerr << "No batch parameters found!" << std::endl; + LMS_LOG(MOD_REMOTE, SEV_ERROR) << "No batch parameters found!"; return false; } diff --git a/remote/server/AuthRequestHandler.cpp b/remote/server/AuthRequestHandler.cpp index 1266392f..938eaab3 100644 --- a/remote/server/AuthRequestHandler.cpp +++ b/remote/server/AuthRequestHandler.cpp @@ -1,5 +1,7 @@ #include +#include "logger/Logger.hpp" + #include "AuthRequestHandler.hpp" namespace Remote { @@ -25,7 +27,7 @@ AuthRequestHandler::process(const AuthRequest& request, AuthResponse& response) response.set_type(AuthResponse::TypePasswordResult); } else - std::cerr << "Bad AuthRequest::TypePassword" << std::endl; + LMS_LOG(MOD_REMOTE, SEV_ERROR) << "Bad AuthRequest::TypePassword"; break; } @@ -69,7 +71,7 @@ AuthRequestHandler::processPassword(const AuthRequest::Password& request, AuthRe } else { - std::cerr << "Invalid user '" << request.user_login() << std::endl; + LMS_LOG(MOD_REMOTE, SEV_ERROR) << "Invalid user '" << request.user_login(); response.set_type(AuthResponse::PasswordResult::TypePasswordInvalid); } diff --git a/remote/server/Connection.cpp b/remote/server/Connection.cpp index afff9d54..c911c874 100644 --- a/remote/server/Connection.cpp +++ b/remote/server/Connection.cpp @@ -5,6 +5,8 @@ #include #include +#include "logger/Logger.hpp" + #include "messages/messages.pb.h" #include "RequestHandler.hpp" @@ -24,13 +26,13 @@ _socket(ioService, context), _connectionManager(manager), _requestHandler(dbPath) { - std::cout << "Server::Connection::Connection, Creating connection" << std::endl; + LMS_LOG(MOD_REMOTE, SEV_DEBUG) << "Server::Connection::Connection, Creating connection"; } void Connection::start() { - std::cout << "Starting connection..." << std::endl; + LMS_LOG(MOD_REMOTE, SEV_DEBUG) << "Starting connection..."; _socket.async_handshake(boost::asio::ssl::stream_base::server, boost::bind(&Connection::handleHandshake, this, boost::asio::placeholders::error)); @@ -41,16 +43,16 @@ Connection::handleHandshake(const boost::system::error_code& error) { if (!error) { - std::cout << "Handshake successfully performed... Now reading messages" << std::endl; + LMS_LOG(MOD_REMOTE, SEV_DEBUG) << "Handshake successfully performed... Now reading messages"; readMsg(); } else if (error != boost::asio::error::operation_aborted) { - std::cerr << "Connection::handleHandshake: " << error.message() << std::endl; + LMS_LOG(MOD_REMOTE, SEV_ERROR) << "Connection::handleHandshake: " << error.message(); _connectionManager.stop(shared_from_this()); } else - std::cerr << "Handshake error: " << error.message() << std::endl; + LMS_LOG(MOD_REMOTE, SEV_ERROR) << "Handshake error: " << error.message(); } @@ -76,16 +78,16 @@ Connection::stop() boost::system::error_code ec; _closing = true; - std::cout << "Server::Connection::stop, Stopping connection " << this << std::endl; + LMS_LOG(MOD_REMOTE, SEV_DEBUG) << "Server::Connection::stop, Stopping connection " << this; _socket.shutdown(ec); if (ec) - std::cerr << "Error while shutting down connection " << this << ": " << ec.message() << std::endl; + LMS_LOG(MOD_REMOTE, SEV_ERROR) << "Error while shutting down connection " << this << ": " << ec.message(); - std::cout << "Server::Connection::stop, connection stopped " << this << std::endl; + LMS_LOG(MOD_REMOTE, SEV_DEBUG) << "Server::Connection::stop, connection stopped " << this; } else - std::cout << "Stop: close already in progress..." << std::endl; + LMS_LOG(MOD_REMOTE, SEV_DEBUG) << "Stop: close already in progress..."; } void @@ -95,7 +97,7 @@ Connection::handleReadHeader(const boost::system::error_code& error, std::size_t { if (bytes_transferred != Remote::Header::size) { - std::cerr << "bytes_transferred (" << bytes_transferred << ") != Remote::Header::size!" << std::endl; + LMS_LOG(MOD_REMOTE, SEV_ERROR) << "bytes_transferred (" << bytes_transferred << ") != Remote::Header::size!"; _connectionManager.stop(shared_from_this()); return; } @@ -107,7 +109,7 @@ Connection::handleReadHeader(const boost::system::error_code& error, std::size_t Remote::Header header; if (!header.from_istream(is)) { - std::cerr << "Cannot read header from buffer!" << std::endl; + LMS_LOG(MOD_REMOTE, SEV_ERROR) << "Cannot read header from buffer!"; _connectionManager.stop(shared_from_this()); return; } @@ -125,7 +127,7 @@ Connection::handleReadHeader(const boost::system::error_code& error, std::size_t } else if (error != boost::asio::error::operation_aborted) { - std::cerr << "Connection::handleReadHeader: " << error.message() << std::endl; + LMS_LOG(MOD_REMOTE, SEV_ERROR) << "Connection::handleReadHeader: " << error.message(); _connectionManager.stop(shared_from_this()); } } @@ -145,14 +147,14 @@ Connection::handleReadMsg(const boost::system::error_code& error, std::size_t by if (!request.ParseFromIstream(&is)) { - std::cerr << "Cannot parse request!" << std::endl; + LMS_LOG(MOD_REMOTE, SEV_ERROR) << "Parse request failed!"; _connectionManager.stop(shared_from_this()); return; } if (!_requestHandler.process(request, response)) { - std::cerr << "Cannot process request!" << std::endl; + LMS_LOG(MOD_REMOTE, SEV_ERROR) << "Process request failed!"; _connectionManager.stop(shared_from_this()); return; } @@ -162,14 +164,14 @@ Connection::handleReadMsg(const boost::system::error_code& error, std::size_t by if (!response.SerializeToOstream(&os)) { - std::cerr << "Cannot serialize to ostream!" << std::endl; + LMS_LOG(MOD_REMOTE, SEV_ERROR) << "Cannot serialize to ostream!"; _connectionManager.stop(shared_from_this()); return; } if (_outputStreamBuf.size() >= Remote::Header::max_data_size) { - std::cerr << "output message is too big! " << _outputStreamBuf.size() << " > " << Remote::Header::max_data_size << std::endl; + LMS_LOG(MOD_REMOTE, SEV_ERROR) << "output message is too big! " << _outputStreamBuf.size() << " > " << Remote::Header::max_data_size; _connectionManager.stop(shared_from_this()); return; } @@ -187,7 +189,7 @@ Connection::handleReadMsg(const boost::system::error_code& error, std::size_t by ec); if (ec) { - std::cerr << "cannot write header: " << error.message() << std::endl; + LMS_LOG(MOD_REMOTE, SEV_ERROR) << "cannot write header: " << error.message(); _connectionManager.stop(shared_from_this()); } else @@ -203,7 +205,7 @@ Connection::handleReadMsg(const boost::system::error_code& error, std::size_t by if (ec) { - std::cerr << "cannot write msg: " << error.message() << std::endl; + LMS_LOG(MOD_REMOTE, SEV_ERROR) << "cannot write msg: " << error.message(); _connectionManager.stop(shared_from_this()); } else @@ -216,15 +218,10 @@ Connection::handleReadMsg(const boost::system::error_code& error, std::size_t by // All good here, read another message readMsg(); - - // Initiate graceful Connection closure. - // boost::system::error_code ignored_ec; - // _socket.shutdown(boost::asio::ip::tcp::socket::shutdown_both, ignored_ec); - } else if (error != boost::asio::error::operation_aborted) { - std::cerr << "Connection::handleRead: " << error.message() << std::endl; + LMS_LOG(MOD_REMOTE, SEV_ERROR) << "Connection::handleRead: " << error.message(); _connectionManager.stop(shared_from_this()); } } diff --git a/remote/server/MediaRequestHandler.cpp b/remote/server/MediaRequestHandler.cpp index d2db9fdf..bd31cfbd 100644 --- a/remote/server/MediaRequestHandler.cpp +++ b/remote/server/MediaRequestHandler.cpp @@ -1,3 +1,5 @@ +#include "logger/Logger.hpp" + #include "MediaRequestHandler.hpp" #include "database/AudioTypes.hpp" @@ -23,31 +25,31 @@ MediaRequestHandler::process(const MediaRequest& request, MediaResponse& respons if (request.prepare().has_audio()) res = processAudioPrepare(request.prepare().audio(), response); else if (request.prepare().has_video()) - ;// TODO; + LMS_LOG(MOD_REMOTE, SEV_ERROR) << "Video prepare not supported!"; else - std::cerr << "Bad MediaRequest::TypeMediaPrepare!" << std::endl; + LMS_LOG(MOD_REMOTE, SEV_ERROR) << "Bad MediaRequest::TypeMediaPrepare!"; } else - std::cerr << "Bad MediaRequest::TypeMediaPrepare!" << std::endl; + LMS_LOG(MOD_REMOTE, SEV_ERROR) << "Bad MediaRequest::TypeMediaPrepare!"; break; case MediaRequest::TypeMediaGetPart: if (request.has_get_part()) res = processGetPart(request.get_part(), response); else - std::cerr << "Bad MediaRequest::TypeMediaGet!" << std::endl; + LMS_LOG(MOD_REMOTE, SEV_ERROR) << "Bad MediaRequest::TypeMediaGet!"; break; case MediaRequest::TypeMediaTerminate: if (request.has_terminate()) res = processTerminate(request.terminate(), response); else - std::cerr << "Bad MediaRequest::TypeMediaTerminate!" << std::endl; + LMS_LOG(MOD_REMOTE, SEV_ERROR) << "Bad MediaRequest::TypeMediaTerminate!"; break; default: - std::cerr << "Unhandled MediaRequest type = " << request.type() << std::endl; + LMS_LOG(MOD_REMOTE, SEV_ERROR) << "Unhandled MediaRequest type = " << request.type(); } return res; @@ -68,7 +70,7 @@ MediaRequestHandler::processAudioPrepare(const MediaRequest::Prepare::Audio& req format = Transcode::Format::OGA; break; default: - std::cerr << "Unhandled codec type = " << request.codec_type() << std::endl; + LMS_LOG(MOD_REMOTE, SEV_ERROR) << "Unhandled codec type = " << request.codec_type(); return false; } } @@ -108,7 +110,7 @@ MediaRequestHandler::processAudioPrepare(const MediaRequest::Prepare::Audio& req } catch(std::exception& e) { - std::cerr << "Caught exception: " << e.what() << std::endl; + LMS_LOG(MOD_REMOTE, SEV_ERROR) << "Caught exception: " << e.what(); response.mutable_error()->set_error(true); response.mutable_error()->set_message("exception: " + std::string(e.what())); response.set_type(MediaResponse::TypeError); @@ -135,7 +137,7 @@ MediaRequestHandler::processGetPart(const MediaRequest::GetPart& request, MediaR while (!_transcoder->isComplete() && _transcoder->getOutputData().size() < dataSize) _transcoder->process(); - std::cout << "MediaRequestHandler::processGetPart, isComplete = " << std::boolalpha << _transcoder->isComplete() << ", size = " << _transcoder->getOutputData().size() << std::endl; + LMS_LOG(MOD_REMOTE, SEV_DEBUG) << "MediaRequestHandler::processGetPart, isComplete = " << std::boolalpha << _transcoder->isComplete() << ", size = " << _transcoder->getOutputData().size(); Transcode::AvConvTranscoder::data_type::iterator itEnd; if (_transcoder->getOutputData().size() > dataSize) @@ -156,7 +158,7 @@ MediaRequestHandler::processGetPart(const MediaRequest::GetPart& request, MediaR bool MediaRequestHandler::processTerminate(const MediaRequest::Terminate& /*request*/, MediaResponse& response) { - std::cout << "MediaRequestHandler: resetting transcoder" << std::endl; + LMS_LOG(MOD_REMOTE, SEV_DEBUG) << "MediaRequestHandler: resetting transcoder"; _transcoder.reset(); assert(!_transcoder); diff --git a/remote/server/RequestHandler.cpp b/remote/server/RequestHandler.cpp index 7c09cb35..99ae5567 100644 --- a/remote/server/RequestHandler.cpp +++ b/remote/server/RequestHandler.cpp @@ -1,3 +1,4 @@ +#include "logger/Logger.hpp" #include "RequestHandler.hpp" @@ -34,7 +35,7 @@ RequestHandler::process(const ClientMessage& request, ServerMessage& response) response.set_type(ServerMessage::AuthResponse); } else - std::cerr << "Bad ClientMessage::AuthRequest !" << std::endl; + LMS_LOG(MOD_REMOTE, SEV_ERROR) << "Bad ClientMessage::AuthRequest !"; break; case ClientMessage::AudioCollectionRequest: // Not allowed if the user is not logged in @@ -47,7 +48,7 @@ RequestHandler::process(const ClientMessage& request, ServerMessage& response) response.set_type( ServerMessage::AudioCollectionResponse); } else - std::cerr << "Bad ClientMessage::AudioCollectionRequest message!" << std::endl; + LMS_LOG(MOD_REMOTE, SEV_ERROR) << "Bad ClientMessage::AudioCollectionRequest message!"; } break; @@ -62,12 +63,12 @@ RequestHandler::process(const ClientMessage& request, ServerMessage& response) response.set_type( ServerMessage::MediaResponse); } else - std::cerr << "Malformed ClientMessage::MediaRequest message!" << std::endl; + LMS_LOG(MOD_REMOTE, SEV_ERROR) << "Malformed ClientMessage::MediaRequest message!"; } break; default: - std::cerr << "Unhandled message type = " << request.type() << std::endl; + LMS_LOG(MOD_REMOTE, SEV_ERROR) << "Unhandled message type = " << request.type(); } return res; diff --git a/remote/server/Server.cpp b/remote/server/Server.cpp index 84c0aecb..9cf6cca4 100644 --- a/remote/server/Server.cpp +++ b/remote/server/Server.cpp @@ -4,6 +4,8 @@ #include #include +#include "logger/Logger.hpp" + #include "Server.hpp" namespace Remote { @@ -56,7 +58,6 @@ Server::asyncAccept() void Server::handleAccept(std::shared_ptr newConnection, boost::system::error_code ec) { - std::cout << "Server::handleAccept..." << std::endl; // Check whether the server was stopped before this // completion handler had a chance to run. if (!_acceptor.is_open()) @@ -73,7 +74,7 @@ Server::handleAccept(std::shared_ptr newConnection, boost::system::e asyncAccept(); } else - std::cerr << "handleAccept: " << ec.message() << std::endl; + LMS_LOG(MOD_REMOTE, SEV_ERROR) << "handleAccept: " << ec.message(); } diff --git a/service/DatabaseUpdateService.cpp b/service/DatabaseUpdateService.cpp index ad4260ed..9956610e 100644 --- a/service/DatabaseUpdateService.cpp +++ b/service/DatabaseUpdateService.cpp @@ -1,5 +1,7 @@ #include +#include "logger/Logger.hpp" + #include "DatabaseUpdateService.hpp" namespace Service { @@ -13,21 +15,22 @@ DatabaseUpdateService::DatabaseUpdateService(const Config& config) void DatabaseUpdateService::start(void) { + LMS_LOG(MOD_SERVICE, SEV_DEBUG) << "DatabaseUpdateService, starting..."; _databaseUpdater.start(); } void DatabaseUpdateService::stop(void) { - std::cout << "DatabaseUpdateService::stop, processing..." << std::endl; + LMS_LOG(MOD_SERVICE, SEV_DEBUG) << "DatabaseUpdateService, stopping..."; _databaseUpdater.stop(); - std::cout << "DatabaseUpdateService::stop, process done" << std::endl; + LMS_LOG(MOD_SERVICE, SEV_DEBUG) << "DatabaseUpdateService, stopped"; } void DatabaseUpdateService::restart(void) { - std::cout << "DatabaseUpdateService::restart" << std::endl; + LMS_LOG(MOD_SERVICE, SEV_DEBUG) << "DatabaseUpdateService, restart"; stop(); start(); } diff --git a/service/RemoteServerService.cpp b/service/RemoteServerService.cpp index f4619eb3..1c255521 100644 --- a/service/RemoteServerService.cpp +++ b/service/RemoteServerService.cpp @@ -1,3 +1,4 @@ +#include "logger/Logger.hpp" #include "RemoteServerService.hpp" @@ -15,24 +16,24 @@ RemoteServerService::RemoteServerService(const Config& config) void RemoteServerService::start(void) { - std::cout << "RemoteServerService::start, starting..." << std::endl; + LMS_LOG(MOD_SERVICE, SEV_DEBUG) << "RemoteServerService::start, starting..."; _server.start(); - std::cout << "RemoteServerService::start, started!" << std::endl; + LMS_LOG(MOD_SERVICE, SEV_DEBUG) << "RemoteServerService::start, started!"; } void RemoteServerService::stop(void) { - std::cout << "RemoteServerService::stop, stopping..." << std::endl; + LMS_LOG(MOD_SERVICE, SEV_DEBUG) << "RemoteServerService::stop, stopping..."; _server.stop(); - std::cout << "RemoteServerService::stop, stopped!" << std::endl; + LMS_LOG(MOD_SERVICE, SEV_DEBUG) << "RemoteServerService::stop, stopped!"; } void RemoteServerService::restart(void) { - std::cout << "RemoteServerService::restart, not implemented!" << std::endl; + LMS_LOG(MOD_SERVICE, SEV_DEBUG) << "RemoteServerService::restart, not implemented!"; } } // namespace Service diff --git a/service/ServiceManager.cpp b/service/ServiceManager.cpp index 9fd6c55a..5fc1ba2a 100644 --- a/service/ServiceManager.cpp +++ b/service/ServiceManager.cpp @@ -1,3 +1,4 @@ +#include "logger/Logger.hpp" #include #include @@ -40,20 +41,20 @@ ServiceManager::run() asyncWaitSignals(); - std::cout << "ServiceManager::run Waiting for events..." << std::endl; + LMS_LOG(MOD_SERVICE, SEV_DEBUG) << "ServiceManager: waiting for events..."; try { // Wait for events _ioService.run(); } catch( std::exception& e ) { - std::cerr << "Caugh exception in service : " << e.what() << std::endl; + LMS_LOG(MOD_SERVICE, SEV_ERROR) << "ServiceManager: exception in ioService::run: " << e.what(); } // Stopping services stopServices(); - std::cout << "ServiceManager::run complete!" << std::endl; + LMS_LOG(MOD_SERVICE, SEV_DEBUG) << "ServiceManager: run complete !"; } void @@ -68,10 +69,8 @@ ServiceManager::asyncWaitSignals(void) void ServiceManager::startService(Service::pointer service) { - std::cout << "ServiceManager::startService" << std::endl; _services.insert(service); service->start(); - std::cout << "ServiceManager::startService done" << std::endl; } void @@ -99,20 +98,20 @@ ServiceManager::restartServices(void) void ServiceManager::handleSignal(boost::system::error_code /*ec*/, int signo) { - std::cout << "Received signal " << signo << std::endl; + LMS_LOG(MOD_SERVICE, SEV_INFO) << "Received signal " << signo; switch (signo) { case SIGINT: case SIGTERM: case SIGQUIT: - std::cout << "Stopping services..." << std::endl; + LMS_LOG(MOD_SERVICE, SEV_NOTICE) << "Stopping services..."; stopServices(); // Do not listen for signals, this will make the ioservice.run return break; case SIGHUP: - std::cout << "Restarting services..." << std::endl; + LMS_LOG(MOD_SERVICE, SEV_NOTICE) << "Restarting services..."; restartServices(); asyncWaitSignals(); diff --git a/service/UserInterfaceService.cpp b/service/UserInterfaceService.cpp index 6f94eb31..985144ab 100644 --- a/service/UserInterfaceService.cpp +++ b/service/UserInterfaceService.cpp @@ -1,4 +1,4 @@ -#include +#include "logger/Logger.hpp" #include "UserInterfaceService.hpp" #include "ui/LmsApplication.hpp" @@ -30,7 +30,7 @@ UserInterfaceService::UserInterfaceService( boost::filesystem::path runAppPath, for(int i = 0; i < argc; ++i) { - std::cout << "i = " << i << ", arg = '" << argv[i] << "'" << std::endl; + LMS_LOG(MOD_SERVICE, SEV_DEBUG) << "i = " << i << ", arg = '" << argv[i] << "'"; } _server.setServerConfiguration (argc, const_cast(argv)); @@ -44,15 +44,15 @@ void UserInterfaceService::start(void) { _server.start(); - std::cout << "UserInterfaceService::start -> Service started..." << std::endl; + LMS_LOG(MOD_SERVICE, SEV_DEBUG) << "UserInterfaceService::start -> Service started..."; } void UserInterfaceService::stop(void) { - std::cout << "UserInterfaceService::stop -> stopping..." << std::endl; + LMS_LOG(MOD_SERVICE, SEV_DEBUG) << "UserInterfaceService::stop -> stopping..."; _server.stop(); - std::cout << "UserInterfaceService::stop -> stopped!" << std::endl; + LMS_LOG(MOD_SERVICE, SEV_DEBUG) << "UserInterfaceService::stop -> stopped!"; } void diff --git a/test/Makefile.am b/test/Makefile.am index 033689b2..127f9e72 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -6,6 +6,7 @@ check_PROGRAMS = database-integrity sql-query database-basics database-user remo remote_SOURCES = \ $(srcdir)/RemoteClientServer.cpp \ $(srcdir)/TestDatabase.cpp \ + $(top_srcdir)/logger/Logger.cpp \ $(top_srcdir)/remote/messages/auth.pb.cc \ $(top_srcdir)/remote/messages/collection.pb.cc \ $(top_srcdir)/remote/messages/common.pb.cc \ @@ -21,10 +22,11 @@ remote_SOURCES = \ $(top_srcdir)/database/Path.cpp \ $(top_srcdir)/database/Video.cpp -remote_CXXFLAGS=-std=c++11 -Wall -Wextra -I$(top_srcdir) -I$(top_srcdir)/remote -I$(top_srcdir)/boost +remote_CXXFLAGS=-std=c++11 -Wall -Wextra -DBOOST_LOG_DYN_LINK -I$(top_srcdir) -I$(top_srcdir)/remote -I$(top_srcdir)/boost database_user_SOURCES = \ $(srcdir)/CheckDatabaseUser.cpp \ + $(top_srcdir)/logger/Logger.cpp \ $(top_srcdir)/database/Artist.cpp \ $(top_srcdir)/database/Genre.cpp \ $(top_srcdir)/database/Release.cpp \ @@ -35,11 +37,12 @@ database_user_SOURCES = \ $(top_srcdir)/database/User.cpp \ $(top_srcdir)/database/Video.cpp -database_user_CXXFLAGS=-std=c++11 -Wall -Wextra -I$(top_srcdir) +database_user_CXXFLAGS=-std=c++11 -Wall -Wextra -DBOOST_LOG_DYN_LINK -I$(top_srcdir) database_integrity_SOURCES = \ $(srcdir)/DatabaseIntegrity.cpp \ + $(top_srcdir)/logger/Logger.cpp \ $(top_srcdir)/database/Artist.cpp \ $(top_srcdir)/database/Genre.cpp \ $(top_srcdir)/database/Release.cpp \ @@ -50,10 +53,11 @@ database_integrity_SOURCES = \ $(top_srcdir)/database/User.cpp \ $(top_srcdir)/database/Video.cpp -database_integrity_CXXFLAGS=-std=c++11 -Wall -Wextra -I$(top_srcdir) +database_integrity_CXXFLAGS=-std=c++11 -Wall -Wextra -DBOOST_LOG_DYN_LINK -I$(top_srcdir) database_basics_SOURCES = \ $(srcdir)/CheckDatabaseBasics.cpp \ + $(top_srcdir)/logger/Logger.cpp \ $(top_srcdir)/database/Artist.cpp \ $(top_srcdir)/database/Genre.cpp \ $(top_srcdir)/database/Release.cpp \ @@ -65,7 +69,7 @@ database_basics_SOURCES = \ $(top_srcdir)/database/User.cpp \ $(top_srcdir)/database/Video.cpp -database_basics_CXXFLAGS=-std=c++11 -Wall -Wextra -I$(top_srcdir) +database_basics_CXXFLAGS=-std=c++11 -Wall -Wextra -DBOOST_LOG_DYN_LINK -I$(top_srcdir) sql_query_SOURCES = \ diff --git a/test/RemoteClientServer.cpp b/test/RemoteClientServer.cpp index 4ea111ef..3c7e4369 100644 --- a/test/RemoteClientServer.cpp +++ b/test/RemoteClientServer.cpp @@ -715,7 +715,7 @@ class TestClient int main() { try { - bool extendedTests = true; + bool extendedTests = false; bool writeCovers = false; std::cout << "Running test... extendedTests = " << std::boolalpha << extendedTests << std::endl; @@ -811,16 +811,16 @@ int main() // ****** Transcode test ******** { std::vector data; - client.getMediaAudio(1, data); + client.getMediaAudio(30000, data); std::cout << "Media size = " << data.size() << std::endl; } - { +/* { std::vector data; client.getMediaAudio(100, data); std::cout << "Media size = " << data.size() << std::endl; - } + }*/ std::cout << "End of tests!" << std::endl; diff --git a/test/database b/test/database old mode 100755 new mode 100644 diff --git a/transcode/AvConvTranscoder.cpp b/transcode/AvConvTranscoder.cpp index be20af38..22ba612b 100644 --- a/transcode/AvConvTranscoder.cpp +++ b/transcode/AvConvTranscoder.cpp @@ -1,11 +1,11 @@ - -#include #include #include #include #include +#include "logger/Logger.hpp" + #include "AvConvTranscoder.hpp" namespace Transcode @@ -19,7 +19,7 @@ void AvConvTranscoder::init() { _avConvPath = boost::process::search_path("avconv"); - std::cout << "Using execPath " << _avConvPath << std::endl; + LMS_LOG(MOD_TRANSCODE, SEV_INFO) << "Using execPath " << _avConvPath; } @@ -41,7 +41,7 @@ AvConvTranscoder::AvConvTranscoder(const Parameters& parameters) throw std::runtime_error("File " + _parameters.getInputMediaFile().getPath().string() + " is not regular!"); } - std::cout << "Transcoding file '" << _parameters.getInputMediaFile().getPath() << "'" << std::endl; + LMS_LOG(MOD_TRANSCODE, SEV_INFO) << "Transcoding file '" << _parameters.getInputMediaFile().getPath() << "'"; // Launch a process to handle the conversion boost::iostreams::file_descriptor_sink sink(_outputPipe.sink, boost::iostreams::close_handle); @@ -108,8 +108,7 @@ AvConvTranscoder::AvConvTranscoder(const Parameters& parameters) } oss << " -"; // output to stdout - - std::cout << "executing... '" << oss.str() << "'" << std::endl; + LMS_LOG(MOD_TRANSCODE, SEV_DEBUG) << "Executing '" << oss.str() << "'"; // make sure only one thread is executing this part of code // See boost process FAQ @@ -141,7 +140,7 @@ AvConvTranscoder::process(void) } if (!_in || _in.fail() || _in.eof()) { - std::cout << "Transcode complete!" << std::endl; + LMS_LOG(MOD_TRANSCODE, SEV_DEBUG) << "Transcode complete!"; waitChild(); _isComplete = true; @@ -151,7 +150,7 @@ AvConvTranscoder::process(void) AvConvTranscoder::~AvConvTranscoder() { - std::cout << "AvConvTranscoder::~AvConvTranscoder called!" << std::endl; + LMS_LOG(MOD_TRANSCODE, SEV_DEBUG) << "~AvConvTranscoder called!"; if (_in.eof()) waitChild(); @@ -166,12 +165,12 @@ AvConvTranscoder::waitChild() { boost::system::error_code ec; - std::cout << "waiting for child!" << std::endl; + LMS_LOG(MOD_TRANSCODE, SEV_DEBUG) << "Waiting for child..."; boost::process::wait_for_exit(*_child, ec); - std::cout << "waiting for child! DONE." << std::endl; + LMS_LOG(MOD_TRANSCODE, SEV_DEBUG) << "Waiting for child: OK"; if (ec) - std::cerr << "AvConvTranscoder::waitChild: error: " << ec.message() << std::endl; + LMS_LOG(MOD_TRANSCODE, SEV_ERROR) << "AvConvTranscoder::waitChild: error: " << ec.message(); _child.reset(); } @@ -184,13 +183,13 @@ AvConvTranscoder::killChild() { boost::system::error_code ec; - std::cout << "Killing child! pid = " << _child->pid << std::endl; + LMS_LOG(MOD_TRANSCODE, SEV_DEBUG) << "Killing child! pid = " << _child->pid; boost::process::terminate(*_child, ec); - std::cout << "Killing child DONE" << std::endl; + LMS_LOG(MOD_TRANSCODE, SEV_DEBUG) << "Killing child DONE"; // If an error occured, force kill the child if (ec) - std::cerr << "AvConvTranscoder::killChild: error: " << ec.message() << std::endl; + LMS_LOG(MOD_TRANSCODE, SEV_ERROR) << "AvConvTranscoder::killChild: error: " << ec.message(); _child.reset(); } diff --git a/transcode/InputMediaFile.cpp b/transcode/InputMediaFile.cpp index 5c491a93..6944fb8f 100644 --- a/transcode/InputMediaFile.cpp +++ b/transcode/InputMediaFile.cpp @@ -1,13 +1,14 @@ #include - #include -#include "InputMediaFile.hpp" +#include "logger/Logger.hpp" #include "av/InputFormatContext.hpp" #include "cover/CoverArtGrabber.hpp" +#include "InputMediaFile.hpp" + namespace Transcode { @@ -71,7 +72,7 @@ InputMediaFile::InputMediaFile(const boost::filesystem::path& p) _bestStreams.insert(std::make_pair( streamType, index) ); } else - std::cerr << "Cannot find best stream for type " << type << std::endl; + LMS_LOG(MOD_TRANSCODE, SEV_WARNING) << "Cannot find best stream for type " << type; } _covers = CoverArt::Grabber::getFromInputFormatContext(input); diff --git a/ui/LmsApplication.cpp b/ui/LmsApplication.cpp index 49ddc697..a1e94544 100644 --- a/ui/LmsApplication.cpp +++ b/ui/LmsApplication.cpp @@ -13,7 +13,6 @@ LmsApplication::create(const Wt::WEnvironment& env, boost::filesystem::path dbPa * You could read information from the environment to decide whether * the user has permission to start a new application */ - std::cout << "Creating new Application" << std::endl; return new LmsApplication(env, dbPath); } diff --git a/ui/audio/AudioDatabaseWidget.cpp b/ui/audio/AudioDatabaseWidget.cpp index c8b3ede1..9c2ddeb2 100644 --- a/ui/audio/AudioDatabaseWidget.cpp +++ b/ui/audio/AudioDatabaseWidget.cpp @@ -72,15 +72,12 @@ AudioDatabaseWidget::handleFilterUpdated(std::size_t idFilterUpdated) _refreshingFilters = true; - std::cout << "FILTER " << idFilterUpdated << " has been UPDATED!" << std::endl; - FilterWidget::Constraint currentConstraint; currentConstraint.where.And( WhereClause( "track.artist_id = artist.id and track.release_id = release.id and track_genre.track_id = track.id and genre.id = track_genre.genre_id")); for (std::size_t idFilter = 0; idFilter < _filters.size(); ++idFilter) { - std::cout << "Processing Filter INDEX " << idFilter << std::endl; FilterWidget* filter = _filters.at(idFilter); // Apply contraints created by previous filters @@ -100,8 +97,6 @@ AudioDatabaseWidget::handleFilterUpdated(std::size_t idFilterUpdated) void AudioDatabaseWidget::selectNextTrack(void) { - std::cout << "Wants to select next track!" << std::endl; - TrackWidget* trackWidget ( dynamic_cast(_filters.back() ) ); trackWidget->selectNextTrack(); diff --git a/ui/audio/AudioMediaPlayerWidget.cpp b/ui/audio/AudioMediaPlayerWidget.cpp index cd31ddfa..88de13f9 100644 --- a/ui/audio/AudioMediaPlayerWidget.cpp +++ b/ui/audio/AudioMediaPlayerWidget.cpp @@ -94,8 +94,6 @@ AudioMediaPlayerWidget::handlePlayOffset(int offsetSecs) if (!_currentParameters) return; - std::cout << "Want to play at offset " << offsetSecs << std::endl;; - _currentParameters->setOffset( boost::posix_time::seconds(offsetSecs) ); loadPlayer(); @@ -107,41 +105,37 @@ AudioMediaPlayerWidget::handlePlayOffset(int offsetSecs) void AudioMediaPlayerWidget::handlePlayNext(void) { - std::cout << "Want to play next!" << std::endl; + // TODO } void AudioMediaPlayerWidget::handlePlayPrev(void) { - std::cout << "Want to play prev!" << std::endl; + // TODO } void AudioMediaPlayerWidget::handleTrackEnded(void) { - std::cout << "Track playback ended!" << std::endl; _playbackEnded.emit(); } void AudioMediaPlayerWidget::handleValueChanged(double value) { - std::cout << "Value changed!" << std::endl; - + // TODO } void AudioMediaPlayerWidget::handleSliderMoved(int value) { - std::cout << "Slider moved to " << value << std::endl; + ; } void AudioMediaPlayerWidget::handleTimeUpdated(void) { - std::cout << "Time updated to " << _mediaPlayer->currentTime() << std::endl; - if (!_currentParameters) return; diff --git a/ui/audio/AudioWidget.cpp b/ui/audio/AudioWidget.cpp index 1a41dcfc..16b4fca6 100644 --- a/ui/audio/AudioWidget.cpp +++ b/ui/audio/AudioWidget.cpp @@ -1,5 +1,7 @@ #include +#include "logger/Logger.hpp" + #include "AudioWidget.hpp" namespace UserInterface { @@ -37,7 +39,7 @@ AudioWidget::search(const std::string& searchText) void AudioWidget::playTrack(boost::filesystem::path p) { - std::cout << "play track '" << p << "'" << std::endl; + LMS_LOG(MOD_UI, SEV_DEBUG) << "play track '" << p << "'"; try { std::size_t bitrate = 0; @@ -65,15 +67,15 @@ AudioWidget::playTrack(boost::filesystem::path p) if (!covers.empty()) { - std::cout << "Cover found!" << std::endl; + LMS_LOG(MOD_UI, SEV_DEBUG) << "Cover found!"; if (!covers.front().scale(256)) - std::cerr << "Cannot resize!" << std::endl; + LMS_LOG(MOD_UI, SEV_ERROR) << "Cannot resize!"; //_imgResource->setMimeType(covers.front().getMimeType()); _imgResource->setData(covers.front().getData()); } else { - std::cout << "No cover found!" << std::endl; + LMS_LOG(MOD_UI, SEV_DEBUG) << "No cover found!"; _imgResource->setData( std::vector()); } @@ -82,14 +84,14 @@ AudioWidget::playTrack(boost::filesystem::path p) } catch( std::exception &e) { - std::cerr <<"Caught exception while loading '" << p << "': " << e.what() << std::endl; + LMS_LOG(MOD_UI, SEV_ERROR) << "Caught exception while loading '" << p << "': " << e.what(); } } void AudioWidget::handleTrackEnded(void) { - std::cout << "Track playback ended!" << std::endl; + LMS_LOG(MOD_UI, SEV_DEBUG) << "Track playback ended!"; _audioDbWidget->selectNextTrack(); } diff --git a/ui/audio/TableFilterWidget.cpp b/ui/audio/TableFilterWidget.cpp index 792c302d..d0a83541 100644 --- a/ui/audio/TableFilterWidget.cpp +++ b/ui/audio/TableFilterWidget.cpp @@ -1,5 +1,7 @@ #include +#include "logger/Logger.hpp" + #include "TableFilterWidget.hpp" namespace UserInterface { @@ -41,20 +43,20 @@ TableFilterWidget::refresh(const Constraint& constraint) SqlQuery AllSqlQuery; AllSqlQuery.select("'',0,1 AS ORDERBY"); - std::cout << _table << ", generated query = '" << sqlQuery.get() + " UNION " + AllSqlQuery.get() << "'" << std::endl; + LMS_LOG(MOD_UI, SEV_DEBUG) << _table << ", generated query = '" << sqlQuery.get() + " UNION " + AllSqlQuery.get() << "'"; Wt::Dbo::Query query = _db.getSession().query( sqlQuery.get() + " UNION " + AllSqlQuery.get() ); query.orderBy("ORDERBY DESC," + _table + "." + _field); BOOST_FOREACH(const std::string& bindArg, sqlQuery.where().getBindArgs()) { - std::cout << "Binding value '" << bindArg << "'" << std::endl; + LMS_LOG(MOD_UI, SEV_DEBUG) << "Binding value '" << bindArg << "'"; query.bind(bindArg); } _queryModel.setQuery( query, true /* Keep columns */); - std::cout << "Finish !" << std::endl; + LMS_LOG(MOD_UI, SEV_DEBUG) << "Finish !"; } // Get constraint created by this filter diff --git a/ui/audio/TrackWidget.cpp b/ui/audio/TrackWidget.cpp index 256c2dd1..5a01c2c9 100644 --- a/ui/audio/TrackWidget.cpp +++ b/ui/audio/TrackWidget.cpp @@ -4,6 +4,8 @@ #include #include +#include "logger/Logger.hpp" + #include "TrackWidget.hpp" namespace UserInterface { @@ -76,14 +78,14 @@ TrackWidget::refresh(const Constraint& constraint) sqlQuery.from().And( FromClause("artist,release,track,genre,track_genre")); sqlQuery.where().And(constraint.where); - std::cout << "TRACK REQ = '" << sqlQuery.get() << "'" << std::endl; + LMS_LOG(MOD_UI, SEV_DEBUG) << "TRACK REQ = '" << sqlQuery.get() << "'"; Wt::Dbo::Query query = _db.getSession().query( sqlQuery.get() ); query.groupBy("track").orderBy("artist.name,track.creation_time,release.name,track.disc_number,track.track_number"); BOOST_FOREACH(const std::string& bindArg, sqlQuery.where().getBindArgs()) { - std::cout << "Binding value '" << bindArg << "'" << std::endl; + LMS_LOG(MOD_UI, SEV_DEBUG) << "Binding value '" << bindArg << "'"; query.bind(bindArg); } diff --git a/ui/resource/AvConvTranscodeStreamResource.cpp b/ui/resource/AvConvTranscodeStreamResource.cpp index e5d23df0..4c1ce102 100644 --- a/ui/resource/AvConvTranscodeStreamResource.cpp +++ b/ui/resource/AvConvTranscodeStreamResource.cpp @@ -1,6 +1,9 @@ #include #include + +#include "logger/Logger.hpp" + #include "AvConvTranscodeStreamResource.hpp" namespace UserInterface { @@ -9,12 +12,12 @@ AvConvTranscodeStreamResource::AvConvTranscodeStreamResource(const Transcode::Pa : Wt::WResource(parent), _parameters( parameters ) { - std::cout << "CONSTRUCTING RESOURCE" << std::endl; + LMS_LOG(MOD_UI, SEV_DEBUG) << "CONSTRUCTING RESOURCE"; } AvConvTranscodeStreamResource::~AvConvTranscodeStreamResource() { - std::cout << "DESTRUCTING RESOURCE" << std::endl; + LMS_LOG(MOD_UI, SEV_DEBUG) << "DESTRUCTING RESOURCE"; beingDeleted(); } @@ -31,7 +34,7 @@ AvConvTranscodeStreamResource::handleRequest(const Wt::Http::Request& request, if (!transcoder) { - std::cout << "Launching transcoder" << std::endl; + LMS_LOG(MOD_UI, SEV_DEBUG) << "Launching transcoder"; transcoder = std::make_shared( _parameters); response.setMimeType(_parameters.getOutputFormat().getMimeType()); @@ -56,10 +59,10 @@ AvConvTranscodeStreamResource::handleRequest(const Wt::Http::Request& request, copiedSize++; } - std::cout << "Wrote " << copiedSize << " bytes" << std::endl; + LMS_LOG(MOD_UI, SEV_DEBUG) << "Wrote " << copiedSize << " bytes"; if (!copySuccess) - std::cerr << "** Write failed!" << std::endl; + LMS_LOG(MOD_UI, SEV_ERROR) << "** Write failed!"; // Consume copied bytes data.erase(data.begin(), data.begin() + copiedSize); @@ -67,10 +70,10 @@ AvConvTranscodeStreamResource::handleRequest(const Wt::Http::Request& request, if (copySuccess && !transcoder->isComplete()) { continuation = response.createContinuation(); continuation->setData(transcoder); - std::cout << "Continuation set!" << std::endl; + LMS_LOG(MOD_UI, SEV_DEBUG) << "Continuation set!"; } else - std::cout << "No more data!" << std::endl; + LMS_LOG(MOD_UI, SEV_DEBUG) << "No more data!"; } } // namespace UserInterface diff --git a/ui/settings/Settings.cpp b/ui/settings/Settings.cpp index d06eaeef..f49e4bf6 100644 --- a/ui/settings/Settings.cpp +++ b/ui/settings/Settings.cpp @@ -10,6 +10,8 @@ #include "SettingsMediaDirectories.hpp" #include "SettingsUsers.hpp" +#include "logger/Logger.hpp" + #include "service/ServiceManager.hpp" #include "service/DatabaseUpdateService.hpp" @@ -67,7 +69,7 @@ _sessionData(sessionData) void Settings::handleDatabaseDirectoriesChanged() { - std::cout << "Media directories have changed: requesting imediate scan" << std::endl; + LMS_LOG(MOD_UI, SEV_NOTICE) << "Media directories have changed: requesting imediate scan"; // On directory add or delete, request an immediate scan { Wt::Dbo::Transaction transaction(_sessionData.getDatabaseHandler().getSession()); diff --git a/ui/settings/SettingsAccountFormView.cpp b/ui/settings/SettingsAccountFormView.cpp index bd34ed75..69a677ec 100644 --- a/ui/settings/SettingsAccountFormView.cpp +++ b/ui/settings/SettingsAccountFormView.cpp @@ -8,6 +8,8 @@ #include #include +#include "logger/Logger.hpp" + #include "common/Validators.hpp" #include "SettingsAccountFormView.hpp" @@ -96,7 +98,7 @@ class AccountFormModel : public Wt::WFormModel } catch(Wt::Dbo::Exception& exception) { - std::cerr << "Dbo exception: " << exception.what() << std::endl; + LMS_LOG(MOD_UI, SEV_ERROR) << "Dbo exception: " << exception.what(); return false; } diff --git a/ui/settings/SettingsAudioFormView.cpp b/ui/settings/SettingsAudioFormView.cpp index 03688d10..36bc864e 100644 --- a/ui/settings/SettingsAudioFormView.cpp +++ b/ui/settings/SettingsAudioFormView.cpp @@ -5,6 +5,8 @@ #include #include +#include "logger/Logger.hpp" + #include "common/Validators.hpp" #include "SettingsAudioFormView.hpp" @@ -64,7 +66,7 @@ class AudioFormModel : public Wt::WFormModel } catch(Wt::Dbo::Exception& exception) { - std::cerr << "Dbo exception: " << exception.what() << std::endl; + LMS_LOG(MOD_UI, SEV_ERROR) << "Dbo exception: " << exception.what(); return false; } diff --git a/ui/settings/SettingsDatabaseFormView.cpp b/ui/settings/SettingsDatabaseFormView.cpp index e26a5fe0..1a8fe8ce 100644 --- a/ui/settings/SettingsDatabaseFormView.cpp +++ b/ui/settings/SettingsDatabaseFormView.cpp @@ -7,6 +7,7 @@ #include #include +#include "logger/Logger.hpp" #include "database/MediaDirectory.hpp" #include "common/DirectoryValidator.hpp" @@ -88,7 +89,7 @@ class DatabaseFormModel : public Wt::WFormModel } catch(Wt::Dbo::Exception& exception) { - std::cerr << "Dbo exception: " << exception.what() << std::endl; + LMS_LOG(MOD_UI, SEV_ERROR) << "Dbo exception: " << exception.what(); return false; } diff --git a/ui/settings/SettingsMediaDirectoryFormView.cpp b/ui/settings/SettingsMediaDirectoryFormView.cpp index f4f5daad..a980e7f8 100644 --- a/ui/settings/SettingsMediaDirectoryFormView.cpp +++ b/ui/settings/SettingsMediaDirectoryFormView.cpp @@ -6,6 +6,7 @@ #include #include +#include "logger/Logger.hpp" #include "database/MediaDirectory.hpp" #include "common/DirectoryValidator.hpp" @@ -62,7 +63,7 @@ class MediaDirectoryFormModel : public Wt::WFormModel } catch(Wt::Dbo::Exception& exception) { - std::cerr << "Dbo exception: " << exception.what() << std::endl; + LMS_LOG(MOD_UI, SEV_ERROR) << "Dbo exception: " << exception.what(); return false; } diff --git a/ui/settings/SettingsUserFormView.cpp b/ui/settings/SettingsUserFormView.cpp index ddd7316b..90aa51d5 100644 --- a/ui/settings/SettingsUserFormView.cpp +++ b/ui/settings/SettingsUserFormView.cpp @@ -8,6 +8,8 @@ #include #include +#include "logger/Logger.hpp" + #include "common/Validators.hpp" #include "SettingsUserFormView.hpp" @@ -147,12 +149,12 @@ class UserFormModel : public Wt::WFormModel // user may have been deleted by someone else if (!authUser.isValid()) { - std::cerr << "user identity does not exist!" << std::endl; + LMS_LOG(MOD_UI, SEV_ERROR) << "user identity does not exist!"; return false; } else if(!user) { - std::cerr << "User not found!" << std::endl; + LMS_LOG(MOD_UI, SEV_ERROR) << "User not found!"; return false; } @@ -185,7 +187,7 @@ class UserFormModel : public Wt::WFormModel } catch(Wt::Dbo::Exception& exception) { - std::cerr << "Dbo exception: " << exception.what() << std::endl; + LMS_LOG(MOD_UI, SEV_ERROR) << "Dbo exception: " << exception.what(); return false; } diff --git a/ui/settings/SettingsUsers.cpp b/ui/settings/SettingsUsers.cpp index 84e966ad..4c3cbfda 100644 --- a/ui/settings/SettingsUsers.cpp +++ b/ui/settings/SettingsUsers.cpp @@ -6,6 +6,8 @@ #include +#include "logger/Logger.hpp" + #include "SettingsUserFormView.hpp" #include "SettingsUsers.hpp" @@ -77,12 +79,12 @@ Users::refresh(void) } catch(Wt::Dbo::Exception& e) { - std::cerr << "Caught exception when getting userId=" << userId << ": " << e.code() << std::endl; + LMS_LOG(MOD_UI, SEV_ERROR) << "Caught exception when getting userId=" << userId << ": " << e.code(); continue; } if (!authUser.isValid()) { - std::cerr << "Users::refresh: skipping invalid userId = " << userId << std::endl; + LMS_LOG(MOD_UI, SEV_ERROR) << "Users::refresh: skipping invalid userId = " << userId; continue; }