🔧 chore: create @manacore/shared-logger and migrate 2 mobile apps

- Create shared logger package with logger, perfLogger, networkLogger
- Support both __DEV__ (React Native) and NODE_ENV environments
- Migrate manadeck and picture mobile apps to use shared package

Savings: ~120 LOC (126 → 10 LOC in apps)
This commit is contained in:
Till-JS 2026-01-29 17:12:48 +01:00
parent 5663c3d3ce
commit 2d16f7c9ff
7 changed files with 254 additions and 129 deletions

View file

@ -1,33 +1,5 @@
/**
* Simple logger utility for consistent logging across the app
* Can be extended to integrate with crash reporting services
* Logger utility - re-exports from shared package
* @see @manacore/shared-logger
*/
const isDevelopment = process.env.NODE_ENV === 'development' || __DEV__;
export const debug = (...args: any[]): void => {
if (isDevelopment) {
console.debug('[DEBUG]', ...args);
}
};
export const info = (...args: any[]): void => {
if (isDevelopment) {
console.info('[INFO]', ...args);
}
};
export const warn = (...args: any[]): void => {
console.warn('[WARN]', ...args);
};
export const error = (...args: any[]): void => {
console.error('[ERROR]', ...args);
// TODO: Send to crash reporting service in production
};
export const log = (...args: any[]): void => {
if (isDevelopment) {
console.log('[LOG]', ...args);
}
};
export { debug, info, warn, error, log, logger } from '@manacore/shared-logger';

View file

@ -1,91 +1,5 @@
/**
* Centralized logging utility
* - Development: Logs to console
* - Production: Logs to console (can be extended for custom error tracking)
* Logger utilities - re-exports from shared package
* @see @manacore/shared-logger
*/
const isDevelopment = __DEV__;
export const logger = {
/**
* Log debug information (only in development)
*/
debug: (...args: any[]) => {
if (isDevelopment) {
console.log('[DEBUG]', ...args);
}
},
/**
* Log general information
*/
info: (...args: any[]) => {
if (isDevelopment) {
console.log('[INFO]', ...args);
}
},
/**
* Log warnings (always logged)
*/
warn: (...args: any[]) => {
console.warn('[WARN]', ...args);
// TODO: Send to error tracking service in production
},
/**
* Log errors (always logged)
*/
error: (...args: any[]) => {
console.error('[ERROR]', ...args);
// In production: can be extended for custom error tracking
},
/**
* Log success messages (only in development)
*/
success: (...args: any[]) => {
if (isDevelopment) {
console.log('[SUCCESS] ✅', ...args);
}
},
};
/**
* Performance logger for measuring execution time
*/
export const perfLogger = {
start: (label: string) => {
if (isDevelopment) {
console.time(label);
}
},
end: (label: string) => {
if (isDevelopment) {
console.timeEnd(label);
}
},
};
/**
* Network request logger
*/
export const networkLogger = {
request: (url: string, method: string, body?: any) => {
if (isDevelopment) {
console.log(`[NETWORK] ${method} ${url}`, body ? { body } : '');
}
},
response: (url: string, status: number, data?: any) => {
if (isDevelopment) {
console.log(`[NETWORK] Response ${status} from ${url}`, data ? { data } : '');
}
},
error: (url: string, error: any) => {
console.error(`[NETWORK] Error from ${url}`, error);
// TODO: Send to error tracking
},
};
export { logger, perfLogger, networkLogger } from '@manacore/shared-logger';