/**
 * Global logger that prefixes all logs with a configurable app tag
 * This makes it easy to filter logs in browser console and logcat
 */
export const useLogger = (context?: string) => {
  const config = useRuntimeConfig()
  const appTag = `[${config.public.appLogTag || 'App'}]`
  const prefix = context ? `${appTag}[${context}]` : appTag

  return {
    log: (...args: unknown[]) => console.log(prefix, ...args),
    info: (...args: unknown[]) => console.info(prefix, ...args),
    warn: (...args: unknown[]) => console.warn(prefix, ...args),
    error: (...args: unknown[]) => console.error(prefix, ...args),
    debug: (...args: unknown[]) => console.debug(prefix, ...args)
  }
}

/**
 * Create a logger instance with a custom app tag
 * Useful for cases where you need a specific tag regardless of config
 */
export const createLogger = (appTag: string) => ({
  log: (...args: unknown[]) => console.log(`[${appTag}]`, ...args),
  info: (...args: unknown[]) => console.info(`[${appTag}]`, ...args),
  warn: (...args: unknown[]) => console.warn(`[${appTag}]`, ...args),
  error: (...args: unknown[]) => console.error(`[${appTag}]`, ...args),
  debug: (...args: unknown[]) => console.debug(`[${appTag}]`, ...args)
})
