Setup onLog event, add app version & platform to logs and share filename

This commit is contained in:
advplyr
2025-04-20 14:33:48 -05:00
parent fe921fd5b1
commit 26b0fae0fb
6 changed files with 61 additions and 9 deletions
+4
View File
@@ -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 -2
View File
@@ -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 = []
}