diff options
Diffstat (limited to 'runTimer.js')
-rw-r--r-- | runTimer.js | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/runTimer.js b/runTimer.js index 4ee6f16..ee3b874 100644 --- a/runTimer.js +++ b/runTimer.js @@ -5,6 +5,28 @@ const { mnemonic } = require('./secret'); const { address, times } = require('./constants'); const lottery = require('./build/contracts/Lottery.json'); +const bunyan = require('bunyan'); + +// Imports the Google Cloud client library for Bunyan +const { LoggingBunyan } = require('@google-cloud/logging-bunyan'); + +// Creates a Bunyan Stackdriver Logging client +const loggingBunyan = new LoggingBunyan(); + +// Create a Bunyan logger that streams to Stackdriver Logging +// Logs will be written to: "projects/YOUR_PROJECT_ID/logs/bunyan_log" +const logger = bunyan.createLogger({ + // The JSON payload of the log as it appears in Stackdriver Logging + // will contain "name": "my-service" + name: 'dexon-lottery', + streams: [ + // Log to the console at 'info' and above + { stream: process.stdout, level: 'info' }, + // And log to Stackdriver Logging, logging at 'info' and above + loggingBunyan.stream('info'), + ], +}); + const web3 = new Web3('https://testnet-rpc.dexon.org'); let account; @@ -21,7 +43,7 @@ const runTime = (time) => { gas: 1000000, }); - console.log('Revealed for: ', time); + logger.info(`Revealed for: ${time}`); }; mnemonicToSeed(mnemonic) @@ -38,3 +60,5 @@ mnemonicToSeed(mnemonic) times.forEach(runTime); }); + +logger.info('Service started'); |