generated from gitea_admin/default
update a lot of change since a while
This commit is contained in:
17
app/utils/clientLog.js
Normal file
17
app/utils/clientLog.js
Normal file
@@ -0,0 +1,17 @@
|
||||
const ALLOWED_LEVELS = ['info', 'warn', 'error'];
|
||||
|
||||
export async function clientLog(level, message, meta = {}) {
|
||||
if (!ALLOWED_LEVELS.includes(level)) {
|
||||
console.warn('clientLog: invalid level, fallback to info', level);
|
||||
level = 'info';
|
||||
}
|
||||
|
||||
try {
|
||||
await $fetch('/api/log', {
|
||||
method: 'POST',
|
||||
body: { level, message, meta }
|
||||
});
|
||||
} catch (e) {
|
||||
console.error('Failed to send client log', e);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user