mirror of
https://github.com/advplyr/audiobookshelf-app.git
synced 2026-07-28 23:48:45 +02:00
Setup onLog event, add app version & platform to logs and share filename
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { registerPlugin, WebPlugin } from '@capacitor/core'
|
||||
import { AbsLogger } from '@/plugins/capacitor'
|
||||
import { nanoid } from 'nanoid'
|
||||
const { PlayerState } = require('../constants')
|
||||
|
||||
@@ -88,6 +89,9 @@ class AbsAudioPlayerWeb extends WebPlugin {
|
||||
return
|
||||
}
|
||||
|
||||
// For testing onLog events in web while on the logs page
|
||||
AbsLogger.info({ tag: 'AbsAudioPlayer', message: 'playPause' })
|
||||
|
||||
if (this.player.paused) this.player.play()
|
||||
else this.player.pause()
|
||||
return {
|
||||
|
||||
@@ -8,15 +8,18 @@ class AbsLoggerWeb extends WebPlugin {
|
||||
}
|
||||
|
||||
saveLog(level, tag, message) {
|
||||
this.logs.push({
|
||||
const log = {
|
||||
id: Math.random().toString(36).substring(2, 15),
|
||||
tag: tag,
|
||||
timestamp: Date.now(),
|
||||
level: level,
|
||||
message: message
|
||||
})
|
||||
}
|
||||
this.logs.push(log)
|
||||
this.notifyListeners('onLog', log)
|
||||
}
|
||||
|
||||
// PluginMethod
|
||||
async info(data) {
|
||||
if (data?.message) {
|
||||
this.saveLog('info', data.tag || '', data.message)
|
||||
@@ -24,6 +27,7 @@ class AbsLoggerWeb extends WebPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
// PluginMethod
|
||||
async error(data) {
|
||||
if (data?.message) {
|
||||
this.saveLog('error', data.tag || '', data.message)
|
||||
@@ -31,12 +35,14 @@ class AbsLoggerWeb extends WebPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
// PluginMethod
|
||||
async getAllLogs() {
|
||||
return {
|
||||
value: this.logs
|
||||
}
|
||||
}
|
||||
|
||||
// PluginMethod
|
||||
async clearLogs() {
|
||||
this.logs = []
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user