aboutsummaryrefslogtreecommitdiffstats
path: root/runTimer.js
diff options
context:
space:
mode:
authorHsuan Lee <boczeratul@gmail.com>2019-04-18 11:03:14 +0800
committerHsuan Lee <boczeratul@gmail.com>2019-04-18 11:03:14 +0800
commit484448a363acaf9e1cb980fb9d5bf202fe37582d (patch)
treed51d5dad6dd08f66c69726c61e573e3819bb7527 /runTimer.js
parent52a4aed93f42d82b19e1d73caf95bf9dbfabe441 (diff)
downloaddexon-lottery-484448a363acaf9e1cb980fb9d5bf202fe37582d.tar
dexon-lottery-484448a363acaf9e1cb980fb9d5bf202fe37582d.tar.gz
dexon-lottery-484448a363acaf9e1cb980fb9d5bf202fe37582d.tar.bz2
dexon-lottery-484448a363acaf9e1cb980fb9d5bf202fe37582d.tar.lz
dexon-lottery-484448a363acaf9e1cb980fb9d5bf202fe37582d.tar.xz
dexon-lottery-484448a363acaf9e1cb980fb9d5bf202fe37582d.tar.zst
dexon-lottery-484448a363acaf9e1cb980fb9d5bf202fe37582d.zip
Add stackdriver loggingHEADmaster
Diffstat (limited to 'runTimer.js')
-rw-r--r--runTimer.js26
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');