Simplified logger configuration, it no longer depends on Wt
This commit is contained in:
@@ -22,7 +22,7 @@
|
||||
#include "services/database/Db.hpp"
|
||||
#include "services/database/Session.hpp"
|
||||
#include "services/database/Track.hpp"
|
||||
#include "utils/Logger.hpp"
|
||||
#include "utils/ILogger.hpp"
|
||||
|
||||
namespace Scanner
|
||||
{
|
||||
@@ -45,13 +45,13 @@ namespace Scanner
|
||||
const Track::pointer track{ Track::find(session, trackId) };
|
||||
if (auto trackMBID{ track->getTrackMBID() })
|
||||
{
|
||||
LMS_LOG(DBUPDATER, INFO) << "Found duplicated track MBID [" << trackMBID->getAsString() << "], file: " << track->getPath().string() << " - " << track->getName();
|
||||
LMS_LOG(DBUPDATER, INFO, "Found duplicated track MBID [" << trackMBID->getAsString() << "], file: " << track->getPath().string() << " - " << track->getName());
|
||||
context.stats.duplicates.emplace_back(ScanDuplicate{ track->getId(), DuplicateReason::SameTrackMBID });
|
||||
context.currentStepStats.processedElems++;
|
||||
_progressCallback(context.currentStepStats);
|
||||
}
|
||||
}
|
||||
|
||||
LMS_LOG(DBUPDATER, DEBUG) << "Found " << context.currentStepStats.processedElems << " duplicated audio files";
|
||||
LMS_LOG(DBUPDATER, DEBUG, "Found " << context.currentStepStats.processedElems << " duplicated audio files");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#include "services/database/Db.hpp"
|
||||
#include "services/database/Cluster.hpp"
|
||||
#include "services/database/Session.hpp"
|
||||
#include "utils/Logger.hpp"
|
||||
#include "utils/ILogger.hpp"
|
||||
#include "utils/Path.hpp"
|
||||
|
||||
namespace Scanner
|
||||
@@ -84,6 +84,6 @@ namespace Scanner
|
||||
return true;
|
||||
});
|
||||
|
||||
LMS_LOG(DBUPDATER, DEBUG) << "Recomputed stats for " << context.currentStepStats.processedElems << " clusters!";
|
||||
LMS_LOG(DBUPDATER, DEBUG, "Recomputed stats for " << context.currentStepStats.processedElems << " clusters!");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
*/
|
||||
|
||||
#include "ScanStepDiscoverFiles.hpp"
|
||||
#include "utils/Logger.hpp"
|
||||
#include "utils/ILogger.hpp"
|
||||
#include "utils/Path.hpp"
|
||||
|
||||
namespace Scanner
|
||||
@@ -42,6 +42,6 @@ namespace Scanner
|
||||
|
||||
context.stats.filesScanned = context.currentStepStats.processedElems;
|
||||
|
||||
LMS_LOG(DBUPDATER, DEBUG) << "Discovered " << context.stats.filesScanned << " files in '" << context.directory << "'";
|
||||
LMS_LOG(DBUPDATER, DEBUG, "Discovered " << context.stats.filesScanned << " files in '" << context.directory << "'");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
#include "services/database/Release.hpp"
|
||||
#include "services/database/Session.hpp"
|
||||
#include "services/database/Track.hpp"
|
||||
#include "utils/Logger.hpp"
|
||||
#include "utils/ILogger.hpp"
|
||||
#include "utils/Path.hpp"
|
||||
|
||||
namespace Scanner
|
||||
@@ -87,14 +87,14 @@ namespace Scanner
|
||||
|
||||
Session& session{ _db.getTLSSession() };
|
||||
|
||||
LMS_LOG(DBUPDATER, DEBUG) << "Checking tracks to be removed...";
|
||||
LMS_LOG(DBUPDATER, DEBUG, "Checking tracks to be removed...");
|
||||
std::size_t trackCount{};
|
||||
|
||||
{
|
||||
auto transaction{ session.createReadTransaction() };
|
||||
trackCount = Track::getCount(session);
|
||||
}
|
||||
LMS_LOG(DBUPDATER, DEBUG) << trackCount << " tracks to be checked...";
|
||||
LMS_LOG(DBUPDATER, DEBUG, trackCount << " tracks to be checked...");
|
||||
|
||||
context.currentStepStats.totalElems = trackCount;
|
||||
|
||||
@@ -143,24 +143,24 @@ namespace Scanner
|
||||
break;
|
||||
}
|
||||
|
||||
LMS_LOG(DBUPDATER, DEBUG) << trackCount << " tracks checked!";
|
||||
LMS_LOG(DBUPDATER, DEBUG, trackCount << " tracks checked!");
|
||||
}
|
||||
|
||||
void ScanStepRemoveOrphanDbFiles::removeOrphanClusters()
|
||||
{
|
||||
LMS_LOG(DBUPDATER, DEBUG) << "Checking orphan clusters...";
|
||||
LMS_LOG(DBUPDATER, DEBUG, "Checking orphan clusters...");
|
||||
removeOrphanEntries<Database::Cluster>(_db.getTLSSession(), _abortScan);
|
||||
}
|
||||
|
||||
void ScanStepRemoveOrphanDbFiles::removeOrphanArtists()
|
||||
{
|
||||
LMS_LOG(DBUPDATER, DEBUG) << "Checking orphan artists...";
|
||||
LMS_LOG(DBUPDATER, DEBUG, "Checking orphan artists...");
|
||||
removeOrphanEntries<Database::Artist>(_db.getTLSSession(), _abortScan);
|
||||
}
|
||||
|
||||
void ScanStepRemoveOrphanDbFiles::removeOrphanReleases()
|
||||
{
|
||||
LMS_LOG(DBUPDATER, DEBUG) << "Checking orphan releases...";
|
||||
LMS_LOG(DBUPDATER, DEBUG, "Checking orphan releases...");
|
||||
removeOrphanEntries<Database::Release>(_db.getTLSSession(), _abortScan);
|
||||
}
|
||||
|
||||
@@ -172,19 +172,19 @@ namespace Scanner
|
||||
// and still belongs to a media directory
|
||||
if (!std::filesystem::exists(p) || !std::filesystem::is_regular_file(p))
|
||||
{
|
||||
LMS_LOG(DBUPDATER, INFO) << "Removing '" << p.string() << "': missing";
|
||||
LMS_LOG(DBUPDATER, INFO, "Removing '" << p.string() << "': missing");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!PathUtils::isPathInRootPath(p, _settings.mediaDirectory, &excludeDirFileName))
|
||||
{
|
||||
LMS_LOG(DBUPDATER, INFO) << "Removing '" << p.string() << "': out of media directory";
|
||||
LMS_LOG(DBUPDATER, INFO, "Removing '" << p.string() << "': out of media directory");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!PathUtils::hasFileAnyExtension(p, _settings.supportedExtensions))
|
||||
{
|
||||
LMS_LOG(DBUPDATER, INFO) << "Removing '" << p.string() << "': file format no longer handled";
|
||||
LMS_LOG(DBUPDATER, INFO, "Removing '" << p.string() << "': file format no longer handled");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -192,7 +192,7 @@ namespace Scanner
|
||||
}
|
||||
catch (std::filesystem::filesystem_error& e)
|
||||
{
|
||||
LMS_LOG(DBUPDATER, ERROR) << "Caught exception while checking file '" << p.string() << "': " << e.what();
|
||||
LMS_LOG(DBUPDATER, ERROR, "Caught exception while checking file '" << p.string() << "': " << e.what());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
#include "services/database/TrackArtistLink.hpp"
|
||||
#include "utils/Exception.hpp"
|
||||
#include "utils/IConfig.hpp"
|
||||
#include "utils/Logger.hpp"
|
||||
#include "utils/ILogger.hpp"
|
||||
#include "utils/Path.hpp"
|
||||
|
||||
using namespace Database;
|
||||
@@ -258,7 +258,7 @@ namespace Scanner
|
||||
|
||||
MetaData::ParserReadStyle getParserReadStyle()
|
||||
{
|
||||
std::string_view readStyle{ Service<IConfig>::get()->getString("scanner-parser-read-style", "accurate") };
|
||||
std::string_view readStyle{ Service<IConfig>::get()->getString("scanner-parser-read-style", "average") };
|
||||
|
||||
if (readStyle == "fast")
|
||||
return MetaData::ParserReadStyle::Fast;
|
||||
@@ -290,7 +290,7 @@ namespace Scanner
|
||||
|
||||
if (ec)
|
||||
{
|
||||
LMS_LOG(DBUPDATER, ERROR) << "Cannot process entry '" << path.string() << "': " << ec.message();
|
||||
LMS_LOG(DBUPDATER, ERROR, "Cannot process entry '" << path.string() << "': " << ec.message());
|
||||
context.stats.errors.emplace_back(ScanError{ path, ScanErrorType::CannotReadFile, ec.message() });
|
||||
}
|
||||
else if (PathUtils::hasFileAnyExtension(path, _settings.supportedExtensions))
|
||||
@@ -319,7 +319,7 @@ namespace Scanner
|
||||
}
|
||||
catch (LmsException& e)
|
||||
{
|
||||
LMS_LOG(DBUPDATER, ERROR) << e.what();
|
||||
LMS_LOG(DBUPDATER, ERROR, e.what());
|
||||
stats.skips++;
|
||||
return;
|
||||
}
|
||||
@@ -365,7 +365,7 @@ namespace Scanner
|
||||
std::error_code ec;
|
||||
if (!std::filesystem::exists(otherTrack->getPath(), ec))
|
||||
{
|
||||
LMS_LOG(DBUPDATER, DEBUG) << "Considering track '" << file.string() << "' moved from '" << otherTrack->getPath() << "'";
|
||||
LMS_LOG(DBUPDATER, DEBUG, "Considering track '" << file.string() << "' moved from '" << otherTrack->getPath() << "'");
|
||||
track = otherTrack;
|
||||
track.modify()->setPath(file);
|
||||
}
|
||||
@@ -384,7 +384,7 @@ namespace Scanner
|
||||
if (!PathUtils::isPathInRootPath(file, _settings.mediaDirectory, &excludeDirFileName))
|
||||
continue;
|
||||
|
||||
LMS_LOG(DBUPDATER, DEBUG) << "Skipped '" << file.string() << "' (similar MBID in '" << otherTrack->getPath().string() << "')";
|
||||
LMS_LOG(DBUPDATER, DEBUG, "Skipped '" << file.string() << "' (similar MBID in '" << otherTrack->getPath().string() << "')");
|
||||
// As this MBID already exists, just remove what we just scanned
|
||||
if (track)
|
||||
{
|
||||
@@ -399,7 +399,7 @@ namespace Scanner
|
||||
// We estimate this is an audio file if the duration is not null
|
||||
if (trackInfo->duration == std::chrono::milliseconds::zero())
|
||||
{
|
||||
LMS_LOG(DBUPDATER, DEBUG) << "Skipped '" << file.string() << "' (duration is 0)";
|
||||
LMS_LOG(DBUPDATER, DEBUG, "Skipped '" << file.string() << "' (duration is 0)");
|
||||
|
||||
// If Track exists here, delete it!
|
||||
if (track)
|
||||
@@ -427,12 +427,12 @@ namespace Scanner
|
||||
if (!track)
|
||||
{
|
||||
track = dbSession.create<Track>(file);
|
||||
LMS_LOG(DBUPDATER, DEBUG) << "Adding '" << file.string() << "'";
|
||||
LMS_LOG(DBUPDATER, DEBUG, "Adding '" << file.string() << "'");
|
||||
stats.additions++;
|
||||
}
|
||||
else
|
||||
{
|
||||
LMS_LOG(DBUPDATER, DEBUG) << "Updating '" << file.string() << "'";
|
||||
LMS_LOG(DBUPDATER, DEBUG, "Updating '" << file.string() << "'");
|
||||
|
||||
stats.updates++;
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
#include "services/database/ScanSettings.hpp"
|
||||
#include "utils/Exception.hpp"
|
||||
#include "utils/IConfig.hpp"
|
||||
#include "utils/Logger.hpp"
|
||||
#include "utils/ILogger.hpp"
|
||||
#include "utils/Path.hpp"
|
||||
#include "utils/Tuple.hpp"
|
||||
|
||||
@@ -82,9 +82,9 @@ namespace Scanner
|
||||
|
||||
ScannerService::~ScannerService()
|
||||
{
|
||||
LMS_LOG(DBUPDATER, INFO) << "Stopping service...";
|
||||
LMS_LOG(DBUPDATER, INFO, "Stopping service...");
|
||||
stop();
|
||||
LMS_LOG(DBUPDATER, INFO) << "Service stopped!";
|
||||
LMS_LOG(DBUPDATER, INFO, "Service stopped!");
|
||||
}
|
||||
|
||||
void ScannerService::start()
|
||||
@@ -113,15 +113,15 @@ namespace Scanner
|
||||
|
||||
void ScannerService::abortScan()
|
||||
{
|
||||
LMS_LOG(DBUPDATER, DEBUG) << "Aborting scan...";
|
||||
LMS_LOG(DBUPDATER, DEBUG, "Aborting scan...");
|
||||
std::scoped_lock lock{ _controlMutex };
|
||||
|
||||
LMS_LOG(DBUPDATER, DEBUG) << "Waiting for the scan to abort...";
|
||||
LMS_LOG(DBUPDATER, DEBUG, "Waiting for the scan to abort...");
|
||||
|
||||
_abortScan = true;
|
||||
_scheduleTimer.cancel();
|
||||
_ioService.stop();
|
||||
LMS_LOG(DBUPDATER, DEBUG) << "Scan abort done!";
|
||||
LMS_LOG(DBUPDATER, DEBUG, "Scan abort done!");
|
||||
|
||||
_abortScan = false;
|
||||
_ioService.start();
|
||||
@@ -167,7 +167,7 @@ namespace Scanner
|
||||
|
||||
void ScannerService::scheduleNextScan()
|
||||
{
|
||||
LMS_LOG(DBUPDATER, DEBUG) << "Scheduling next scan";
|
||||
LMS_LOG(DBUPDATER, DEBUG, "Scheduling next scan");
|
||||
|
||||
refreshScanSettings();
|
||||
|
||||
@@ -202,7 +202,7 @@ namespace Scanner
|
||||
break;
|
||||
|
||||
case ScanSettings::UpdatePeriod::Never:
|
||||
LMS_LOG(DBUPDATER, INFO) << "Auto scan disabled!";
|
||||
LMS_LOG(DBUPDATER, INFO, "Auto scan disabled!");
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -230,7 +230,7 @@ namespace Scanner
|
||||
|
||||
if (dateTime.isNull())
|
||||
{
|
||||
LMS_LOG(DBUPDATER, INFO) << "Scheduling next scan right now";
|
||||
LMS_LOG(DBUPDATER, INFO, "Scheduling next scan right now");
|
||||
_scheduleTimer.expires_from_now(std::chrono::seconds{ 0 });
|
||||
_scheduleTimer.async_wait(cb);
|
||||
}
|
||||
@@ -240,7 +240,7 @@ namespace Scanner
|
||||
std::time_t t{ std::chrono::system_clock::to_time_t(timePoint) };
|
||||
char ctimeStr[26];
|
||||
|
||||
LMS_LOG(DBUPDATER, INFO) << "Scheduling next scan at " << std::string(::ctime_r(&t, ctimeStr));
|
||||
LMS_LOG(DBUPDATER, INFO, "Scheduling next scan at " << std::string(::ctime_r(&t, ctimeStr)));
|
||||
_scheduleTimer.expires_at(timePoint);
|
||||
_scheduleTimer.async_wait(cb);
|
||||
}
|
||||
@@ -257,7 +257,7 @@ namespace Scanner
|
||||
}
|
||||
|
||||
|
||||
LMS_LOG(UI, INFO) << "New scan started!";
|
||||
LMS_LOG(UI, INFO, "New scan started!");
|
||||
|
||||
refreshScanSettings();
|
||||
|
||||
@@ -267,16 +267,16 @@ namespace Scanner
|
||||
|
||||
for (auto& scanStep : _scanSteps)
|
||||
{
|
||||
LMS_LOG(DBUPDATER, DEBUG) << "Starting scan step '" << scanStep->getStepName() << "'";
|
||||
LMS_LOG(DBUPDATER, DEBUG, "Starting scan step '" << scanStep->getStepName() << "'");
|
||||
scanContext.currentStepStats = ScanStepStats{ Wt::WDateTime::currentDateTime(), scanStep->getStep() };
|
||||
|
||||
notifyInProgress(scanContext.currentStepStats);
|
||||
scanStep->process(scanContext);
|
||||
notifyInProgress(scanContext.currentStepStats);
|
||||
LMS_LOG(DBUPDATER, DEBUG) << "Completed scan step '" << scanStep->getStepName() << "'";
|
||||
LMS_LOG(DBUPDATER, DEBUG, "Completed scan step '" << scanStep->getStepName() << "'");
|
||||
}
|
||||
|
||||
LMS_LOG(DBUPDATER, INFO) << "Scan " << (_abortScan ? "aborted" : "complete") << ". Changes = " << stats.nbChanges() << " (added = " << stats.additions << ", removed = " << stats.deletions << ", updated = " << stats.updates << "), Not changed = " << stats.skips << ", Scanned = " << stats.scans << " (errors = " << stats.errors.size() << "), features fetched = " << stats.featuresFetched << ", duplicates = " << stats.duplicates.size();
|
||||
LMS_LOG(DBUPDATER, INFO, "Scan " << (_abortScan ? "aborted" : "complete") << ". Changes = " << stats.nbChanges() << " (added = " << stats.additions << ", removed = " << stats.deletions << ", updated = " << stats.updates << "), Not changed = " << stats.skips << ", Scanned = " << stats.scans << " (errors = " << stats.errors.size() << "), features fetched = " << stats.featuresFetched << ", duplicates = " << stats.duplicates.size());
|
||||
|
||||
_dbSession.analyze();
|
||||
|
||||
@@ -290,14 +290,14 @@ namespace Scanner
|
||||
_currentScanStepStats.reset();
|
||||
}
|
||||
|
||||
LMS_LOG(DBUPDATER, DEBUG) << "Scan not aborted, scheduling next scan!";
|
||||
LMS_LOG(DBUPDATER, DEBUG, "Scan not aborted, scheduling next scan!");
|
||||
scheduleNextScan();
|
||||
|
||||
_events.scanComplete.emit(stats);
|
||||
}
|
||||
else
|
||||
{
|
||||
LMS_LOG(DBUPDATER, DEBUG) << "Scan aborted, not scheduling next scan!";
|
||||
LMS_LOG(DBUPDATER, DEBUG, "Scan aborted, not scheduling next scan!");
|
||||
|
||||
std::unique_lock lock{ _statusMutex };
|
||||
|
||||
@@ -312,9 +312,9 @@ namespace Scanner
|
||||
if (_settings == newSettings)
|
||||
return;
|
||||
|
||||
LMS_LOG(DBUPDATER, DEBUG) << "Scanner settings updated";
|
||||
LMS_LOG(DBUPDATER, DEBUG) << "skipDuplicateMBID = " << newSettings.skipDuplicateMBID;
|
||||
LMS_LOG(DBUPDATER, DEBUG) << "Using scan settings version " << newSettings.scanVersion;
|
||||
LMS_LOG(DBUPDATER, DEBUG, "Scanner settings updated");
|
||||
LMS_LOG(DBUPDATER, DEBUG, "skipDuplicateMBID = " << newSettings.skipDuplicateMBID);
|
||||
LMS_LOG(DBUPDATER, DEBUG, "Using scan settings version " << newSettings.scanVersion);
|
||||
|
||||
_settings = std::move(newSettings);
|
||||
|
||||
@@ -366,7 +366,7 @@ namespace Scanner
|
||||
|
||||
std::transform(std::cbegin(clusterTypes), std::cend(clusterTypes),
|
||||
std::inserter(clusterTypeNames, clusterTypeNames.begin()),
|
||||
[](ClusterType::pointer clusterType) { return clusterType->getName(); });
|
||||
[](const ClusterType::pointer& clusterType) { return std::string{ clusterType->getName() }; });
|
||||
|
||||
newSettings.clusterTypeNames = std::move(clusterTypeNames);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user