Hapi Console
so colours
much lightweight
such better
wow
~ Eek 2016
Install
npm i --save hapi-console
Quick Example
const Hapi = ;const server = debug: false ;const hapiConsole = ; server;
Note: userFilter
has been deprecated in favour of custom
since 0.6.0
Options
options.ignore {Array.<String>}
Will not write to console output from the route's context but will log errors
options.ignoreSyscall {Boolean}
Will not write to console output any syscall errors
options.userFilter {Object.<String, Boolean>}
Will filter what data from request.auth.credentials
is shown in the output
Interpreting the output
Server start
Example:
SERVER test/2 STARTED
ID: Stefan:26747:itfodt15
PORT: 8081
HOST: Stefan
PROTOCOL: http
URI: http://Stefan:8081
Explanation:
SERVER {connection assigned labels split by /} STARTED
ID: {connection id}
PORT: {port}
HOST: {host}
PROTOCOL: {protocol}
URI: {full uri}
Server Log
server.log(['log', 'test'], 'this is a server log');
Example:
1474629596922:Stefan:26747:itfodt0w | [log/test] this is a server log
Explanation:
{ timestamp }:{host}:{pid}:{ts base64} | [{tags}] {message}
Request Log
req.log(['log', 'test'], 'request log');
Example:
1474629596915:Stefan:26747:itfodt0w:10000:8080 [test|1] 127.0.0.1 [{uid: 12345}] [log/test] log 1
Explanation:
{ timestamp }:{host}:{pid}:{ts base64}:{counter}:{port} [{connection labels}] {ip} [{user data}] [{tags}] {message}
Request Error
req.log('error', new Error('¯\\_(ツ)_/¯')
Example:
1474629596915:Stefan:26747:itfodt0w:10000:8080 [test|1] 127.0.0.1 [null] [ERROR] Error ¯\_(ツ)_/¯ \n {stack}
Explanation:
{ timestamp }:{host}:{pid}:{ts base64}:{counter}:{port} [{connection labels}] {ip} [{user data}] [ERROR] {error stack trace}
Reply
res({success: true}}
Example:
1474629596915:Stefan:26747:itfodt0w:10000:8080 [test|1] 127.0.0.1 [{uid: 1234}] 200 GET:/ 0.74[0.02~0+0.28~0.42]
Explanation:
{ timestamp }:{host}:{pid}:{ts base64}:{counter}:{port} [{connection labels}] {ip} [{user data}] {status code} {method}:{path} {total time ms}[{traffic in time + hapi head}~{auth time ms}+{handler time ms}~{traffic out time + hapi tail}]
Info: if the times don't add up that's because there's also time spent inside the `HAPI` server code
Unexpected Error
throw 'up'
Example:
1474629596915:Stefan:26747:itfodt0w:10000:8080 [test|1] 127.0.0.1 [null] [ERROR] Error: Uncaught error: up
Explanation:
{ timestamp }:{host}:{pid}:{ts base64}:{counter}:{port} [{connection labels}] {ip} [{user data}] [ERROR] {error stack trace}
Colors:
Colors will enable automatically
Force colors off
Use --no-color
or --color=false
Force colors on
Use --color
, --color=true
or --color=always
License
Please see license.md