@sentio/sdk 1.32.2 → 1.32.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/loader.js CHANGED
@@ -12,7 +12,7 @@ function load(name) {
12
12
  path = req.resolve(name);
13
13
  }
14
14
  const module = { module: req(path), name, path };
15
- console.log('Load successfully: ', name);
15
+ console.log('Processor Load successfully');
16
16
  return module;
17
17
  }
18
18
  catch (err) {
package/lib/loader.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"loader.js","sourceRoot":"","sources":["../src/loader.ts"],"names":[],"mappings":";;;AAAA,SAAgB,IAAI,CAAC,IAAY;IAC/B,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,CAAA;IAE3B,IAAI;QACF,IAAI,IAAY,CAAA;QAChB,IAAI;YACF,IAAI,GAAG,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,CAAA;SACrD;QAAC,MAAM;YACN,IAAI,GAAG,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;SACzB;QAED,MAAM,MAAM,GAAG,EAAE,MAAM,EAAE,GAAG,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAA;QAChD,OAAO,CAAC,GAAG,CAAC,qBAAqB,EAAE,IAAI,CAAC,CAAA;QACxC,OAAO,MAAM,CAAA;KACd;IAAC,OAAO,GAAG,EAAE;QACZ,IAAI,GAAG,YAAY,KAAK,IAAI,GAAG,CAAC,OAAO,CAAC,UAAU,CAAC,uBAAuB,IAAI,GAAG,CAAC,EAAE;YAClF,yBAAyB;YACzB,OAAO,CAAC,GAAG,CAAC,4BAA4B,EAAE,IAAI,CAAC,CAAA;YAC/C,OAAO,SAAS,CAAA;SACjB;aAAM;YACL,MAAM,GAAG,CAAA;SACV;KACF;AACH,CAAC;AAvBD,oBAuBC","sourcesContent":["export function load(name: string): { module: any; name: string; path: string } | undefined {\n const req = eval('require')\n\n try {\n let path: string\n try {\n path = req.resolve(name, { paths: [process.cwd()] })\n } catch {\n path = req.resolve(name)\n }\n\n const module = { module: req(path), name, path }\n console.log('Load successfully: ', name)\n return module\n } catch (err) {\n if (err instanceof Error && err.message.startsWith(`Cannot find module '${name}'`)) {\n // this error is expected\n console.log(\"Couldn't load (expected): \", name)\n return undefined\n } else {\n throw err\n }\n }\n}\n"]}
1
+ {"version":3,"file":"loader.js","sourceRoot":"","sources":["../src/loader.ts"],"names":[],"mappings":";;;AAAA,SAAgB,IAAI,CAAC,IAAY;IAC/B,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,CAAA;IAE3B,IAAI;QACF,IAAI,IAAY,CAAA;QAChB,IAAI;YACF,IAAI,GAAG,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,CAAA;SACrD;QAAC,MAAM;YACN,IAAI,GAAG,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;SACzB;QAED,MAAM,MAAM,GAAG,EAAE,MAAM,EAAE,GAAG,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAA;QAChD,OAAO,CAAC,GAAG,CAAC,6BAA6B,CAAC,CAAA;QAC1C,OAAO,MAAM,CAAA;KACd;IAAC,OAAO,GAAG,EAAE;QACZ,IAAI,GAAG,YAAY,KAAK,IAAI,GAAG,CAAC,OAAO,CAAC,UAAU,CAAC,uBAAuB,IAAI,GAAG,CAAC,EAAE;YAClF,yBAAyB;YACzB,OAAO,CAAC,GAAG,CAAC,4BAA4B,EAAE,IAAI,CAAC,CAAA;YAC/C,OAAO,SAAS,CAAA;SACjB;aAAM;YACL,MAAM,GAAG,CAAA;SACV;KACF;AACH,CAAC;AAvBD,oBAuBC","sourcesContent":["export function load(name: string): { module: any; name: string; path: string } | undefined {\n const req = eval('require')\n\n try {\n let path: string\n try {\n path = req.resolve(name, { paths: [process.cwd()] })\n } catch {\n path = req.resolve(name)\n }\n\n const module = { module: req(path), name, path }\n console.log('Processor Load successfully')\n return module\n } catch (err) {\n if (err instanceof Error && err.message.startsWith(`Cannot find module '${name}'`)) {\n // this error is expected\n console.log(\"Couldn't load (expected): \", name)\n return undefined\n } else {\n throw err\n }\n }\n}\n"]}
@@ -1,19 +1,44 @@
1
1
  #!/usr/bin/env node
2
2
  "use strict";
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
16
+ }) : function(o, v) {
17
+ o["default"] = v;
18
+ });
19
+ var __importStar = (this && this.__importStar) || function (mod) {
20
+ if (mod && mod.__esModule) return mod;
21
+ var result = {};
22
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
23
+ __setModuleDefault(result, mod);
24
+ return result;
25
+ };
3
26
  var __importDefault = (this && this.__importDefault) || function (mod) {
4
27
  return (mod && mod.__esModule) ? mod : { "default": mod };
5
28
  };
6
29
  Object.defineProperty(exports, "__esModule", { value: true });
30
+ const path_1 = __importDefault(require("path"));
31
+ const fs_extra_1 = __importDefault(require("fs-extra"));
32
+ const util = __importStar(require("util"));
7
33
  const command_line_args_1 = __importDefault(require("command-line-args"));
8
34
  const nice_grpc_1 = require("nice-grpc");
35
+ const winston_1 = require("winston");
36
+ const compression_algorithms_1 = require("@grpc/grpc-js/build/src/compression-algorithms");
9
37
  const gen_1 = require("./gen");
10
38
  const service_1 = require("./service");
11
39
  const provider_1 = require("./provider");
12
- const path_1 = __importDefault(require("path"));
13
- const fs_extra_1 = __importDefault(require("fs-extra"));
14
40
  const processor_state_1 = require("./state/processor-state");
15
41
  const loader_1 = require("./loader");
16
- const compression_algorithms_1 = require("@grpc/grpc-js/build/src/compression-algorithms");
17
42
  const endpoints_1 = require("./endpoints");
18
43
  global.PROCESSOR_STATE = new processor_state_1.ProcessorState();
19
44
  global.ENDPOINTS = new endpoints_1.Endpoints();
@@ -30,15 +55,41 @@ const optionDefinitions = [
30
55
  },
31
56
  { name: 'chainquery-server', type: String, defaultValue: '' },
32
57
  { name: 'pricefeed-server', type: String, defaultValue: '' },
58
+ { name: 'log-format', type: String, defaultValue: 'console' },
59
+ { name: 'debug', type: Boolean, defaultValue: false },
33
60
  ];
34
61
  const options = (0, command_line_args_1.default)(optionDefinitions, { partial: true });
35
- console.log('loading', options.target);
62
+ if (options['log-format'] === 'json') {
63
+ const utilFormatter = {
64
+ transform: (info) => {
65
+ const args = info[Symbol.for('splat')];
66
+ if (args) {
67
+ info.message = util.format(info.message, ...args);
68
+ }
69
+ return info;
70
+ },
71
+ };
72
+ const logger = (0, winston_1.createLogger)({
73
+ format: winston_1.format.combine(winston_1.format.timestamp({ format: 'YYYY-MM-DDTHH:mm:ssZ' }), utilFormatter, winston_1.format.errors({ stack: true }), winston_1.format.json()),
74
+ transports: [new winston_1.transports.Console()],
75
+ });
76
+ console.log = (...args) => logger.info.call(logger, ...args);
77
+ console.info = (...args) => logger.info.call(logger, ...args);
78
+ console.warn = (...args) => logger.warn.call(logger, ...args);
79
+ console.error = (...args) => logger.error.call(logger, ...args);
80
+ console.debug = (...args) => logger.debug.call(logger, ...args);
81
+ }
82
+ if (options.debug) {
83
+ console.log('Starting with', options.target);
84
+ }
36
85
  const fullPath = path_1.default.resolve(options['chains-config']);
37
86
  const chainsConfig = fs_extra_1.default.readJsonSync(fullPath);
38
87
  (0, provider_1.setProvider)(chainsConfig, options.concurrency, options['use-chainserver']);
39
88
  globalThis.ENDPOINTS.chainQueryAPI = options['chainquery-server'];
40
89
  globalThis.ENDPOINTS.priceFeedAPI = options['pricefeed-server'];
41
- console.log('Start Server', options);
90
+ if (options.debug) {
91
+ console.log('Starting Server', options);
92
+ }
42
93
  const server = (0, nice_grpc_1.createServer)({
43
94
  'grpc.max_send_message_length': 128 * 1024 * 1024,
44
95
  'grpc.max_receive_message_length': 128 * 1024 * 1024,
@@ -47,4 +98,5 @@ const server = (0, nice_grpc_1.createServer)({
47
98
  const service = new service_1.ProcessorServiceImpl(() => (0, loader_1.load)(options.target), server.shutdown);
48
99
  server.add(gen_1.ProcessorDefinition, service);
49
100
  server.listen('0.0.0.0:' + options.port);
101
+ console.log('Processor Server Started');
50
102
  //# sourceMappingURL=processor-runner.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"processor-runner.js","sourceRoot":"","sources":["../src/processor-runner.ts"],"names":[],"mappings":";;;;;;AAEA,0EAA+C;AAC/C,yCAAwC;AACxC,+BAA2C;AAC3C,uCAAgD;AAChD,yCAAwC;AAExC,gDAAuB;AACvB,wDAAyB;AACzB,6DAAwD;AACxD,qCAA+B;AAC/B,2FAAsF;AACtF,2CAAuC;AAEvC,MAAM,CAAC,eAAe,GAAG,IAAI,gCAAc,EAAE,CAAA;AAC7C,MAAM,CAAC,SAAS,GAAG,IAAI,qBAAS,EAAE,CAAA;AAElC,MAAM,iBAAiB,GAAG;IACxB,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,aAAa,EAAE,IAAI,EAAE;IACrD,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE;IAChE,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,EAAE,YAAY,EA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AAC,CAAA;AAEF,MAAM,OAAO,GAAG,IAAI,8BAAoB,CAAC,GAAG,EAAE,CAAC,IAAA,aAAI,EAAC,OAAO,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAA;AACrF,MAAM,CAAC,GAAG,CAAC,yBAAmB,EAAE,OAAO,CAAC,CAAA;AAExC,MAAM,CAAC,MAAM,CAAC,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA","sourcesContent":["#!/usr/bin/env node\n\nimport commandLineArgs from 'command-line-args'\nimport { createServer } from 'nice-grpc'\nimport { ProcessorDefinition } from './gen'\nimport { ProcessorServiceImpl } from './service'\nimport { setProvider } from './provider'\n\nimport path from 'path'\nimport fs from 'fs-extra'\nimport { ProcessorState } from './state/processor-state'\nimport { load } from './loader'\nimport { CompressionAlgorithms } from '@grpc/grpc-js/build/src/compression-algorithms'\nimport { Endpoints } from './endpoints'\n\nglobal.PROCESSOR_STATE = new ProcessorState()\nglobal.ENDPOINTS = new Endpoints()\n\nconst optionDefinitions = [\n { name: 'target', type: String, defaultOption: true },\n { name: 'port', alias: 'p', type: String, defaultValue: '4000' },\n { name: 'concurrency', type: Number, defaultValue: 4 },\n { name: 'use-chainserver', type: Boolean, defaultValue: false },\n {\n name: 'chains-config',\n alias: 'c',\n type: String,\n defaultValue: 'chains-config.json',\n },\n { name: 'chainquery-server', type: String, defaultValue: '' },\n { name: 'pricefeed-server', type: String, defaultValue: '' },\n]\n\nconst options = commandLineArgs(optionDefinitions, { partial: true })\n\nconsole.log('loading', options.target)\n\nconst fullPath = path.resolve(options['chains-config'])\nconst chainsConfig = fs.readJsonSync(fullPath)\n\nsetProvider(chainsConfig, options.concurrency, options['use-chainserver'])\nglobalThis.ENDPOINTS.chainQueryAPI = options['chainquery-server']\nglobalThis.ENDPOINTS.priceFeedAPI = options['pricefeed-server']\n\nconsole.log('Start Server', options)\n\nconst server = createServer({\n 'grpc.max_send_message_length': 128 * 1024 * 1024,\n 'grpc.max_receive_message_length': 128 * 1024 * 1024,\n 'grpc.default_compression_algorithm': CompressionAlgorithms.gzip,\n})\n\nconst service = new ProcessorServiceImpl(() => load(options.target), server.shutdown)\nserver.add(ProcessorDefinition, service)\n\nserver.listen('0.0.0.0:' + options.port)\n"]}
1
+ {"version":3,"file":"processor-runner.js","sourceRoot":"","sources":["../src/processor-runner.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,gDAAuB;AACvB,wDAAyB;AACzB,2CAA4B;AAE5B,0EAA+C;AAC/C,yCAAwC;AACxC,qCAA0D;AAC1D,2FAAsF;AAEtF,+BAA2C;AAC3C,uCAAgD;AAChD,yCAAwC;AACxC,6DAAwD;AACxD,qCAA+B;AAC/B,2CAAuC;AAEvC,MAAM,CAAC,eAAe,GAAG,IAAI,gCAAc,EAAE,CAAA;AAC7C,MAAM,CAAC,SAAS,GAAG,IAAI,qBAAS,EAAE,CAAA;AAElC,MAAM,iBAAiB,GAAG;IACxB,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,aAAa,EAAE,IAAI,EAAE;IACrD,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE;IAChE,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC,EAAE;IACtD,EAAE,IAAI,EAAE,iBAAiB,EAAE,IAAI,EAAE,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE;IAC/D;QACE,IAAI,EAAE,eAAe;QACrB,KAAK,EAAE,GAAG;QACV,IAAI,EAAE,MAAM;QACZ,YAAY,EAAE,oBAAoB;KACnC;IACD,EAAE,IAAI,EAAE,mBAAmB,EAAE,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,EAAE,EAAE;IAC7D,EAAE,IAAI,EAAE,kBAAkB,EAAE,IAAI,EAAE,MAAM,EAAE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iC,EAAE,GAAG,GAAG,IAAI,GAAG,IAAI;IACpD,oCAAoC,EAAE,8CAAqB,CAAC,IAAI;CACjE,CAAC,CAAA;AAEF,MAAM,OAAO,GAAG,IAAI,8BAAoB,CAAC,GAAG,EAAE,CAAC,IAAA,aAAI,EAAC,OAAO,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAA;AACrF,MAAM,CAAC,GAAG,CAAC,yBAAmB,EAAE,OAAO,CAAC,CAAA;AAExC,MAAM,CAAC,MAAM,CAAC,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;AAExC,OAAO,CAAC,GAAG,CAAC,0BAA0B,CAAC,CAAA","sourcesContent":["#!/usr/bin/env node\n\nimport path from 'path'\nimport fs from 'fs-extra'\nimport * as util from 'util'\n\nimport commandLineArgs from 'command-line-args'\nimport { createServer } from 'nice-grpc'\nimport { createLogger, transports, format } from 'winston'\nimport { CompressionAlgorithms } from '@grpc/grpc-js/build/src/compression-algorithms'\n\nimport { ProcessorDefinition } from './gen'\nimport { ProcessorServiceImpl } from './service'\nimport { setProvider } from './provider'\nimport { ProcessorState } from './state/processor-state'\nimport { load } from './loader'\nimport { Endpoints } from './endpoints'\n\nglobal.PROCESSOR_STATE = new ProcessorState()\nglobal.ENDPOINTS = new Endpoints()\n\nconst optionDefinitions = [\n { name: 'target', type: String, defaultOption: true },\n { name: 'port', alias: 'p', type: String, defaultValue: '4000' },\n { name: 'concurrency', type: Number, defaultValue: 4 },\n { name: 'use-chainserver', type: Boolean, defaultValue: false },\n {\n name: 'chains-config',\n alias: 'c',\n type: String,\n defaultValue: 'chains-config.json',\n },\n { name: 'chainquery-server', type: String, defaultValue: '' },\n { name: 'pricefeed-server', type: String, defaultValue: '' },\n { name: 'log-format', type: String, defaultValue: 'console' },\n { name: 'debug', type: Boolean, defaultValue: false },\n]\n\nconst options = commandLineArgs(optionDefinitions, { partial: true })\n\nif (options['log-format'] === 'json') {\n const utilFormatter = {\n transform: (info: any) => {\n const args = info[Symbol.for('splat')]\n if (args) {\n info.message = util.format(info.message, ...args)\n }\n return info\n },\n }\n const logger = createLogger({\n format: format.combine(\n format.timestamp({ format: 'YYYY-MM-DDTHH:mm:ssZ' }),\n utilFormatter,\n format.errors({ stack: true }),\n format.json()\n ),\n transports: [new transports.Console()],\n })\n\n console.log = (...args) => logger.info.call(logger, ...args)\n console.info = (...args) => logger.info.call(logger, ...args)\n console.warn = (...args) => logger.warn.call(logger, ...args)\n console.error = (...args) => logger.error.call(logger, ...args)\n console.debug = (...args) => logger.debug.call(logger, ...args)\n}\nif (options.debug) {\n console.log('Starting with', options.target)\n}\n\nconst fullPath = path.resolve(options['chains-config'])\nconst chainsConfig = fs.readJsonSync(fullPath)\n\nsetProvider(chainsConfig, options.concurrency, options['use-chainserver'])\nglobalThis.ENDPOINTS.chainQueryAPI = options['chainquery-server']\nglobalThis.ENDPOINTS.priceFeedAPI = options['pricefeed-server']\n\nif (options.debug) {\n console.log('Starting Server', options)\n}\n\nconst server = createServer({\n 'grpc.max_send_message_length': 128 * 1024 * 1024,\n 'grpc.max_receive_message_length': 128 * 1024 * 1024,\n 'grpc.default_compression_algorithm': CompressionAlgorithms.gzip,\n})\n\nconst service = new ProcessorServiceImpl(() => load(options.target), server.shutdown)\nserver.add(ProcessorDefinition, service)\n\nserver.listen('0.0.0.0:' + options.port)\n\nconsole.log('Processor Server Started')\n"]}
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@sentio/sdk",
3
3
  "license": "Apache-2.0",
4
- "version": "1.32.2",
4
+ "version": "1.32.4",
5
5
  "scripts": {
6
6
  "compile_target": "yarn tsc -b src/target-ethers-sentio/tsconfig.json",
7
7
  "compile": "tsc -p . && cp src/cli/webpack.config.js lib/cli && cp src/utils/*.csv lib/utils",
8
8
  "build": "yarn gen && yarn compile",
9
- "start_ts": "ts-node --files src/processor-runner.ts ../examples/x2y2/src/processor.ts",
9
+ "start_ts": "ts-node --files src/processor-runner.ts --log-format=json ../examples/x2y2/src/processor.ts",
10
10
  "start": "ts-node --files src/processor-runner.ts ../examples/aptos/dist/lib.js",
11
11
  "start_js": "node lib/processor-runner.js ../examples/aptos/dist/lib.js",
12
12
  "ts-start": "ts-node --files src/processor-runner.ts ./src/anyswap/src/processor.ts",
@@ -50,7 +50,8 @@
50
50
  "ts-loader": "^9.3.0",
51
51
  "typechain": "^8.0.0",
52
52
  "webpack": "^5.72.1",
53
- "webpack-cli": "^4.9.2"
53
+ "webpack-cli": "^4.9.2",
54
+ "winston": "^3.8.2"
54
55
  },
55
56
  "resolutions": {
56
57
  "@grpc/grpc-js": "1.7.3"
package/src/loader.ts CHANGED
@@ -10,7 +10,7 @@ export function load(name: string): { module: any; name: string; path: string }
10
10
  }
11
11
 
12
12
  const module = { module: req(path), name, path }
13
- console.log('Load successfully: ', name)
13
+ console.log('Processor Load successfully')
14
14
  return module
15
15
  } catch (err) {
16
16
  if (err instanceof Error && err.message.startsWith(`Cannot find module '${name}'`)) {
@@ -1,16 +1,19 @@
1
1
  #!/usr/bin/env node
2
2
 
3
+ import path from 'path'
4
+ import fs from 'fs-extra'
5
+ import * as util from 'util'
6
+
3
7
  import commandLineArgs from 'command-line-args'
4
8
  import { createServer } from 'nice-grpc'
9
+ import { createLogger, transports, format } from 'winston'
10
+ import { CompressionAlgorithms } from '@grpc/grpc-js/build/src/compression-algorithms'
11
+
5
12
  import { ProcessorDefinition } from './gen'
6
13
  import { ProcessorServiceImpl } from './service'
7
14
  import { setProvider } from './provider'
8
-
9
- import path from 'path'
10
- import fs from 'fs-extra'
11
15
  import { ProcessorState } from './state/processor-state'
12
16
  import { load } from './loader'
13
- import { CompressionAlgorithms } from '@grpc/grpc-js/build/src/compression-algorithms'
14
17
  import { Endpoints } from './endpoints'
15
18
 
16
19
  global.PROCESSOR_STATE = new ProcessorState()
@@ -29,11 +32,41 @@ const optionDefinitions = [
29
32
  },
30
33
  { name: 'chainquery-server', type: String, defaultValue: '' },
31
34
  { name: 'pricefeed-server', type: String, defaultValue: '' },
35
+ { name: 'log-format', type: String, defaultValue: 'console' },
36
+ { name: 'debug', type: Boolean, defaultValue: false },
32
37
  ]
33
38
 
34
39
  const options = commandLineArgs(optionDefinitions, { partial: true })
35
40
 
36
- console.log('loading', options.target)
41
+ if (options['log-format'] === 'json') {
42
+ const utilFormatter = {
43
+ transform: (info: any) => {
44
+ const args = info[Symbol.for('splat')]
45
+ if (args) {
46
+ info.message = util.format(info.message, ...args)
47
+ }
48
+ return info
49
+ },
50
+ }
51
+ const logger = createLogger({
52
+ format: format.combine(
53
+ format.timestamp({ format: 'YYYY-MM-DDTHH:mm:ssZ' }),
54
+ utilFormatter,
55
+ format.errors({ stack: true }),
56
+ format.json()
57
+ ),
58
+ transports: [new transports.Console()],
59
+ })
60
+
61
+ console.log = (...args) => logger.info.call(logger, ...args)
62
+ console.info = (...args) => logger.info.call(logger, ...args)
63
+ console.warn = (...args) => logger.warn.call(logger, ...args)
64
+ console.error = (...args) => logger.error.call(logger, ...args)
65
+ console.debug = (...args) => logger.debug.call(logger, ...args)
66
+ }
67
+ if (options.debug) {
68
+ console.log('Starting with', options.target)
69
+ }
37
70
 
38
71
  const fullPath = path.resolve(options['chains-config'])
39
72
  const chainsConfig = fs.readJsonSync(fullPath)
@@ -42,7 +75,9 @@ setProvider(chainsConfig, options.concurrency, options['use-chainserver'])
42
75
  globalThis.ENDPOINTS.chainQueryAPI = options['chainquery-server']
43
76
  globalThis.ENDPOINTS.priceFeedAPI = options['pricefeed-server']
44
77
 
45
- console.log('Start Server', options)
78
+ if (options.debug) {
79
+ console.log('Starting Server', options)
80
+ }
46
81
 
47
82
  const server = createServer({
48
83
  'grpc.max_send_message_length': 128 * 1024 * 1024,
@@ -54,3 +89,5 @@ const service = new ProcessorServiceImpl(() => load(options.target), server.shut
54
89
  server.add(ProcessorDefinition, service)
55
90
 
56
91
  server.listen('0.0.0.0:' + options.port)
92
+
93
+ console.log('Processor Server Started')