Added some debug logs during scans, quite verbose

This commit is contained in:
emeric
2024-12-19 20:36:50 +01:00
parent 4c2be63e94
commit ac4baaac10
12 changed files with 39 additions and 0 deletions
@@ -325,6 +325,7 @@ namespace lms::scanner
AudioFileScanOperation& operator=(const AudioFileScanOperation&) = delete;
private:
const std::filesystem::path& getFile() const override { return _file; };
core::LiteralString getName() const override { return "ScanAudioFile"; }
void scan() override;
void processResult(ScanContext& context) override;
@@ -603,6 +604,11 @@ namespace lms::scanner
AudioFileScanner::~AudioFileScanner() = default;
core::LiteralString AudioFileScanner::getName() const
{
return "Audio scanner";
}
std::span<const std::filesystem::path> AudioFileScanner::getSupportedExtensions() const
{
return _metadataParser->getSupportedExtensions();
@@ -50,6 +50,7 @@ namespace lms::scanner
AudioFileScanner& operator=(const AudioFileScanner&) = delete;
private:
core::LiteralString getName() const override;
std::span<const std::filesystem::path> getSupportedExtensions() const override;
bool needsScan(ScanContext& context, const FileToScan& file) const override;
std::unique_ptr<IFileScanOperation> createScanOperation(const FileToScan& fileToScan) const override;
@@ -19,6 +19,8 @@
#pragma once
#include <filesystem>
#include "core/LiteralString.hpp"
namespace lms::scanner
@@ -31,6 +33,8 @@ namespace lms::scanner
virtual ~IFileScanOperation() = default;
virtual core::LiteralString getName() const = 0;
virtual const std::filesystem::path& getFile() const = 0;
virtual void scan() = 0;
virtual void processResult(ScanContext& context) = 0;
};
@@ -22,6 +22,8 @@
#include <filesystem>
#include <span>
#include "core/LiteralString.hpp"
#include "MediaLibraryInfo.hpp"
namespace lms::scanner
@@ -41,6 +43,7 @@ namespace lms::scanner
public:
virtual ~IFileScanner() = default;
virtual core::LiteralString getName() const = 0;
virtual std::span<const std::filesystem::path> getSupportedExtensions() const = 0;
virtual bool needsScan(ScanContext& context, const FileToScan& file) const = 0;
virtual std::unique_ptr<IFileScanOperation> createScanOperation(const FileToScan& fileToScan) const = 0;
@@ -46,6 +46,7 @@ namespace lms::scanner
, _db{ db } {}
private:
const std::filesystem::path& getFile() const override { return _file; };
core::LiteralString getName() const override { return "ScanImageFile"; }
void scan() override;
void processResult(ScanContext& context) override;
@@ -134,6 +135,11 @@ namespace lms::scanner
{
}
core::LiteralString ImageFileScanner::getName() const
{
return "Image scanner";
}
std::span<const std::filesystem::path> ImageFileScanner::getSupportedExtensions() const
{
return image::getSupportedFileExtensions();
@@ -42,6 +42,7 @@ namespace lms::scanner
ImageFileScanner& operator=(const ImageFileScanner&) = delete;
private:
core::LiteralString getName() const override;
std::span<const std::filesystem::path> getSupportedExtensions() const override;
bool needsScan(ScanContext& context, const FileToScan& file) const override;
std::unique_ptr<IFileScanOperation> createScanOperation(const FileToScan& fileToScan) const override;
@@ -46,6 +46,7 @@ namespace lms::scanner
, _db{ db } {}
private:
const std::filesystem::path& getFile() const override { return _file; };
core::LiteralString getName() const override { return "ScanLyricsFile"; }
void scan() override;
void processResult(ScanContext& context) override;
@@ -137,6 +138,11 @@ namespace lms::scanner
{
}
core::LiteralString LyricsFileScanner::getName() const
{
return "Lyrics scanner";
}
std::span<const std::filesystem::path> LyricsFileScanner::getSupportedExtensions() const
{
return metadata::getSupportedLyricsFileExtensions();
@@ -42,6 +42,7 @@ namespace lms::scanner
LyricsFileScanner& operator=(const LyricsFileScanner&) = delete;
private:
core::LiteralString getName() const override;
std::span<const std::filesystem::path> getSupportedExtensions() const override;
bool needsScan(ScanContext& context, const FileToScan& file) const override;
std::unique_ptr<IFileScanOperation> createScanOperation(const FileToScan& fileToScan) const override;
@@ -50,6 +50,7 @@ namespace lms::scanner
PlayListFileScanOperation& operator=(const PlayListFileScanOperation&) = delete;
private:
const std::filesystem::path& getFile() const override { return _file; };
core::LiteralString getName() const override { return "ScanPlayListFile"; }
void scan() override;
void processResult(ScanContext& context) override;
@@ -136,6 +137,11 @@ namespace lms::scanner
{
}
core::LiteralString PlayListFileScanner::getName() const
{
return "PlayList scanner";
}
std::span<const std::filesystem::path> PlayListFileScanner::getSupportedExtensions() const
{
return metadata::getSupportedPlayListFileExtensions();
@@ -42,6 +42,7 @@ namespace lms::scanner
PlayListFileScanner& operator=(const PlayListFileScanner&) = delete;
private:
core::LiteralString getName() const override;
std::span<const std::filesystem::path> getSupportedExtensions() const override;
bool needsScan(ScanContext& context, const FileToScan& file) const override;
std::unique_ptr<IFileScanOperation> createScanOperation(const FileToScan& fileToScan) const override;
@@ -21,6 +21,7 @@
#include <boost/asio/post.hpp>
#include "core/ILogger.hpp"
#include "core/ITraceLogger.hpp"
#include "scanners/IFileScanOperation.hpp"
@@ -52,6 +53,7 @@ namespace lms::scanner
{
{
LMS_SCOPED_TRACE_OVERVIEW("Scanner", operation->getName());
LMS_LOG(DBUPDATER, DEBUG, operation->getName() << ": scanning file '" << operation->getFile().string() << "'");
operation->scan();
}
@@ -57,6 +57,7 @@ namespace lms::scanner
{
[[maybe_unused]] auto [it, inserted]{ _scannerByExtension.emplace(extension, scanner) };
assert(inserted);
LMS_LOG(DBUPDATER, INFO, "Registered extension '" << extension.string() << "' for '" << scanner->getName() << "'");
}
}
@@ -139,6 +140,7 @@ namespace lms::scanner
if (_abortScan)
return;
LMS_LOG(DBUPDATER, DEBUG, scanOperation->getName() << ": processing result for '" << scanOperation->getFile().string() << "'");
scanOperation->processResult(context);
context.stats.scans++;
}