Add more logging to sqlite backend
This commit is contained in:
parent
14d915fb7c
commit
c0e2ab0129
@ -3,24 +3,27 @@
|
|||||||
const Track = require('./track');
|
const Track = require('./track');
|
||||||
|
|
||||||
class SqliteBackend {
|
class SqliteBackend {
|
||||||
constructor(config, db) {
|
constructor(config, db, logger) {
|
||||||
this.config = config;
|
this.config = config;
|
||||||
this.db = db;
|
this.db = db;
|
||||||
|
this.logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
find(tag, callback) {
|
find(tag, callback) {
|
||||||
this.db.run("INSERT INTO tags (tag) VALUES (?)", tag);
|
this.db.run("INSERT INTO tags (tag) VALUES (?)", tag);
|
||||||
this.db.get("SELECT uuid, tag, label FROM library WHERE tag = ? ORDER BY RANDOM() LIMIT 1", tag, (err, row) => {
|
this.db.get("SELECT uuid, tag, label FROM library WHERE tag = ? ORDER BY RANDOM() LIMIT 1", tag, (err, row) => {
|
||||||
if (typeof row === 'undefined') {
|
if (typeof row === 'undefined') {
|
||||||
|
this.logger.debug("no matching tag in sqlite backend", { tag: tag });
|
||||||
return callback();
|
return callback();
|
||||||
}
|
}
|
||||||
|
this.logger.debug("found a matching tag", { tag: tag });
|
||||||
callback(new Track(row['tag'], row['uuid'], row['label']));
|
callback(new Track(row['tag'], row['uuid'], row['label']));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = function(config, db) {
|
module.exports = function(config, db, logger) {
|
||||||
return new SqliteBackend(config, db);
|
return new SqliteBackend(config, db, logger);
|
||||||
};
|
};
|
||||||
|
|
||||||
// vim:ts=2 sw=2 et:
|
// vim:ts=2 sw=2 et:
|
||||||
|
@ -45,7 +45,7 @@ const play_log = require('./jukebox/library/play-log');
|
|||||||
const sqlite3 = require('sqlite3');
|
const sqlite3 = require('sqlite3');
|
||||||
var db = new sqlite3.Database(config.db);
|
var db = new sqlite3.Database(config.db);
|
||||||
|
|
||||||
const MediaLibrarySqliteBackend = require('./jukebox/library/sqlite-backend')(config, db);
|
const MediaLibrarySqliteBackend = require('./jukebox/library/sqlite-backend')(config, db, logger);
|
||||||
const MediaLibrary = new library.Library(config, MediaLibrarySqliteBackend);
|
const MediaLibrary = new library.Library(config, MediaLibrarySqliteBackend);
|
||||||
|
|
||||||
const PlayLog = new play_log.PlayLog();
|
const PlayLog = new play_log.PlayLog();
|
||||||
|
Loading…
Reference in New Issue
Block a user