feat: Implement UI enhancements and fix burst bug
This commit is contained in:
@@ -5,6 +5,11 @@ const logFileUri = FileSystem.documentDirectory + 'app_logs.txt';
|
||||
// Queue to serialize file operations and prevent race conditions
|
||||
const logQueue: string[] = [];
|
||||
let isWriting = false;
|
||||
let isEnabled = true;
|
||||
|
||||
export const setLogsEnabled = (enabled: boolean) => {
|
||||
isEnabled = enabled;
|
||||
};
|
||||
|
||||
const processLogQueue = async () => {
|
||||
if (isWriting) return;
|
||||
@@ -48,6 +53,7 @@ const enqueueWrite = async (logLine: string) => {
|
||||
|
||||
export const logger = {
|
||||
log: async (message: string) => {
|
||||
if (!isEnabled) return;
|
||||
const timestamp = new Date().toISOString();
|
||||
const logLine = `[INFO] ${timestamp}: ${message}\n`;
|
||||
console.log(logLine.trim());
|
||||
@@ -55,6 +61,10 @@ export const logger = {
|
||||
},
|
||||
|
||||
error: async (message: string, error?: any) => {
|
||||
if (!isEnabled) {
|
||||
console.error(`[ERROR]: ${message}`, error);
|
||||
return;
|
||||
}
|
||||
const timestamp = new Date().toISOString();
|
||||
let errorString = '';
|
||||
if (error) {
|
||||
|
||||
Reference in New Issue
Block a user