WIP. Logger for every modules

This commit is contained in:
emeric
2014-08-27 21:25:02 +02:00
parent 6afc4ac291
commit 07624995e7
42 changed files with 292 additions and 223 deletions
-1
View File
@@ -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);
}
-5
View File
@@ -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<TrackWidget*>(_filters.back() ) );
trackWidget->selectNextTrack();
+4 -10
View File
@@ -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;
+8 -6
View File
@@ -1,5 +1,7 @@
#include <Wt/WBreak>
#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<unsigned char>());
}
@@ -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();
}
+5 -3
View File
@@ -1,5 +1,7 @@
#include <boost/foreach.hpp>
#include "logger/Logger.hpp"
#include "TableFilterWidget.hpp"
namespace UserInterface {
@@ -41,20 +43,20 @@ TableFilterWidget::refresh(const Constraint& constraint)
SqlQuery AllSqlQuery;
AllSqlQuery.select("'<All>',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<ResultType> query = _db.getSession().query<ResultType>( 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
+4 -2
View File
@@ -4,6 +4,8 @@
#include <Wt/WItemDelegate>
#include <Wt/WBreak>
#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<ResultType> query = _db.getSession().query<ResultType>( 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);
}
+10 -7
View File
@@ -1,6 +1,9 @@
#include <Wt/Http/Request>
#include <Wt/Http/Response>
#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<Transcode::AvConvTranscoder>( _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
+3 -1
View File
@@ -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());
+3 -1
View File
@@ -8,6 +8,8 @@
#include <Wt/WPushButton>
#include <Wt/Auth/Identity>
#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;
}
+3 -1
View File
@@ -5,6 +5,8 @@
#include <Wt/WComboBox>
#include <Wt/WPushButton>
#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;
}
+2 -1
View File
@@ -7,6 +7,7 @@
#include <Wt/WFormModel>
#include <Wt/WStringListModel>
#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;
}
@@ -6,6 +6,7 @@
#include <Wt/WComboBox>
#include <Wt/WPushButton>
#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;
}
+5 -3
View File
@@ -8,6 +8,8 @@
#include <Wt/WPushButton>
#include <Wt/Auth/Identity>
#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;
}
+4 -2
View File
@@ -6,6 +6,8 @@
#include <Wt/Auth/Identity>
#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;
}