-
Notifications
You must be signed in to change notification settings - Fork 38
/
Copy pathlogging.js
27 lines (21 loc) · 903 Bytes
/
logging.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
'use strict'
/**
* This example demonstrates how you can use bluebird's custom catch
* functionality to respond to different error types.
*
* Here we use the EnvVarError type to catch an error. If you run the program
* without setting CATCH_ERROR it will print "we got an env-var error"
*/
const defaultJsonArray = JSON.stringify(['luke', 'leia', 'lando', 'chewie'])
// Load the from and logger functions from env-var
const { from, logger } = require('../env-var')
// Create an env-var instance and pass it the buitl-in logger
const env = from(process.env, {}, logger)
// Read variables (this will print logs if NODE_ENV isn't "prod" or "production")
const home = env.get('HOME').asString()
const users = env.get('USERNAMES')
.example(defaultJsonArray)
.default(defaultJsonArray)
.asJsonArray()
console.log('\nFetched HOME value:', home)
console.log('Fetched USERNAMES value:', users)