2
0

logger.js 510 B

123456789101112131415
  1. const isLogEnabled = (process.env.LDAP_LOG_ENABLED === 'true');
  2. function log (level, message, data) {
  3. if (isLogEnabled) {
  4. console.log(`[${level}] ${message} ${ data ? JSON.stringify(data, null, 2) : '' }`);
  5. }
  6. }
  7. function log_debug (...args) { log('DEBUG', ...args); }
  8. function log_info (...args) { log('INFO', ...args); }
  9. function log_warn (...args) { log('WARN', ...args); }
  10. function log_error (...args) { log('ERROR', ...args); }
  11. export { log, log_debug, log_info, log_warn, log_error };