Aurélien Georget bd91a2ef93 Add 'packages/strapi-plugin-settings-manager/' from commit 'cd241c14c6a6239bca279e7accd709ba58e87cc8'
git-subtree-dir: packages/strapi-plugin-settings-manager
git-subtree-mainline: 80aa83d8460c95366547e143c74bf79ea6ae69f8
git-subtree-split: cd241c14c6a6239bca279e7accd709ba58e87cc8
2017-01-15 20:14:40 +01:00

38 lines
1.1 KiB
JavaScript

/* eslint-disable no-console */
const chalk = require('chalk');
const ip = require('ip');
const divider = chalk.gray('\n-----------------------------------');
/**
* Logger middleware, you can customize it to make messages more personal
*/
const logger = {
// Called whenever there's an error on the server we want to print
error: (err) => {
console.error(chalk.red(err));
},
// Called when express.js app starts on given port w/o errors
appStarted: (port, tunnelStarted) => {
console.log(`Server started ${chalk.green('✓')}`);
// If the tunnel started, log that and the URL it's available at
if (tunnelStarted) {
console.log(`Tunnel initialised ${chalk.green('✓')}`);
}
console.log(`
${chalk.bold('Access URLs:')}${divider}
Localhost: ${chalk.magenta(`http://localhost:${port}`)}
LAN: ${chalk.magenta(`http://${ip.address()}:${port}`) +
(tunnelStarted ? `\n Proxy: ${chalk.magenta(tunnelStarted)}` : '')}${divider}
${chalk.blue(`Press ${chalk.italic('CTRL-C')} to stop`)}
`);
},
};
module.exports = logger;