export function _formatMessage(level, message, context) {
  const time = new Date().toISOString()
  try {
    const ctx = context ? ` ${JSON.stringify(context)}` : ''
    return `${time} [${level}] ${message}${ctx}`
  } catch (_e) {
    return `${time} [${level}] ${message}`
  }
}

export function info(message, context) {
  console.log(_formatMessage('info', message, context))
}

export function warn(message, context) {
  console.warn(_formatMessage('warn', message, context))
}

export function error(message, context) {
  console.error(_formatMessage('error', message, context))
}

export default {
  info,
  warn,
  error
}
