const {makeLogger} = require('@applitools/logger')

module.exports = function ({mode, dirname, level}) {
  // Print logs in terminal when running execution-grid-tunnel in development mode (with `npm run start`)
  const logHandler =
    mode === 'development'
      ? {type: 'console'}
      : {
          type: 'rolling file',
          name: 'execution-grid-tunnel',
          dirname,
        }

  const logger = makeLogger({
    handler: logHandler,
    label: 'execution-grid-tunnel',
    level,
    colors: true,
  })

  return logger
}
