feat: add expo mobile application source code
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
import { ApiService } from '../services/api';
|
||||
|
||||
class Logger {
|
||||
private logs: string[] = [];
|
||||
private maxLogs = 50;
|
||||
|
||||
log(message: string, type: 'info' | 'error' | 'sync' | 'success' = 'info') {
|
||||
const timestamp = new Date().toLocaleTimeString();
|
||||
const entry = `[${timestamp}] [${type.toUpperCase()}] ${message}`;
|
||||
this.logs.unshift(entry);
|
||||
|
||||
if (this.logs.length > this.maxLogs) {
|
||||
this.logs.pop();
|
||||
}
|
||||
|
||||
if (type === 'error') {
|
||||
ApiService.reportError(message, 'error').catch(() => {});
|
||||
}
|
||||
|
||||
if (__DEV__) {
|
||||
console.log(entry);
|
||||
}
|
||||
}
|
||||
|
||||
getLogs() {
|
||||
return this.logs;
|
||||
}
|
||||
|
||||
clear() {
|
||||
this.logs = [];
|
||||
}
|
||||
}
|
||||
|
||||
export const DebugLogger = new Logger();
|
||||
Reference in New Issue
Block a user