initialize git, basic setup for crm
This commit is contained in:
66
src/utils/logger.js
Normal file
66
src/utils/logger.js
Normal file
@@ -0,0 +1,66 @@
|
||||
/**
|
||||
* Simple logger utility
|
||||
*/
|
||||
|
||||
const colors = {
|
||||
reset: '\x1b[0m',
|
||||
red: '\x1b[31m',
|
||||
green: '\x1b[32m',
|
||||
yellow: '\x1b[33m',
|
||||
blue: '\x1b[34m',
|
||||
magenta: '\x1b[35m',
|
||||
cyan: '\x1b[36m',
|
||||
};
|
||||
|
||||
const getTimestamp = () => {
|
||||
return new Date().toISOString();
|
||||
};
|
||||
|
||||
export const logger = {
|
||||
info: (message, ...args) => {
|
||||
console.log(
|
||||
`${colors.blue}[INFO]${colors.reset} ${getTimestamp()} - ${message}`,
|
||||
...args
|
||||
);
|
||||
},
|
||||
|
||||
success: (message, ...args) => {
|
||||
console.log(
|
||||
`${colors.green}[SUCCESS]${colors.reset} ${getTimestamp()} - ${message}`,
|
||||
...args
|
||||
);
|
||||
},
|
||||
|
||||
warn: (message, ...args) => {
|
||||
console.warn(
|
||||
`${colors.yellow}[WARN]${colors.reset} ${getTimestamp()} - ${message}`,
|
||||
...args
|
||||
);
|
||||
},
|
||||
|
||||
error: (message, error, ...args) => {
|
||||
console.error(
|
||||
`${colors.red}[ERROR]${colors.reset} ${getTimestamp()} - ${message}`,
|
||||
...args
|
||||
);
|
||||
if (error && process.env.NODE_ENV === 'development') {
|
||||
console.error(error);
|
||||
}
|
||||
},
|
||||
|
||||
debug: (message, ...args) => {
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
console.log(
|
||||
`${colors.cyan}[DEBUG]${colors.reset} ${getTimestamp()} - ${message}`,
|
||||
...args
|
||||
);
|
||||
}
|
||||
},
|
||||
|
||||
audit: (message, ...args) => {
|
||||
console.log(
|
||||
`${colors.magenta}[AUDIT]${colors.reset} ${getTimestamp()} - ${message}`,
|
||||
...args
|
||||
);
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user