@ditjenpajakri/elasticsearch-logging 1.1.0 → 2.0.1

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.
Files changed (2) hide show
  1. package/lib.js +10 -8
  2. package/package.json +2 -2
package/lib.js CHANGED
@@ -43,10 +43,9 @@ function initializeBulkHandler (opts, client, splitter) {
43
43
  }
44
44
 
45
45
  return {
46
- index: {
46
+ create: {
47
47
  _index: getIndexName(date),
48
- _type: type,
49
- op_type: opType
48
+ // _type: type,
50
49
  }
51
50
  }
52
51
  },
@@ -66,7 +65,7 @@ function initializeBulkHandler (opts, client, splitter) {
66
65
  if (buildIndexName) {
67
66
  return buildIndexName(time)
68
67
  }
69
- return index.replace('%{DATE}', time.substring(0, 10))
68
+ return index.replace('%{DATE}', time.substring ? time.substring(0, 10) : "")
70
69
  }
71
70
  }
72
71
 
@@ -93,11 +92,11 @@ function pinoElasticSearch(opts = {}) {
93
92
  if (typeof value !== 'object') {
94
93
  value = {
95
94
  data: value,
96
- time: setDateTimeString(value)
95
+ ['@timestamp']: setDateTimeString(value)
97
96
  }
98
97
  } else {
99
98
  if (value['@timestamp'] === undefined) {
100
- value.time = setDateTimeString(value)
99
+ value['@timestamp'] = setDateTimeString(value)
101
100
  }
102
101
  }
103
102
  return value
@@ -107,7 +106,9 @@ function pinoElasticSearch(opts = {}) {
107
106
  node: opts.node,
108
107
  auth: opts.auth,
109
108
  // cloud: opts.cloud,
110
- ssl: { rejectUnauthorized: opts.rejectUnauthorized, ...opts.tls }
109
+ tls: {
110
+ rejectUnauthorized: false
111
+ }
111
112
  }
112
113
 
113
114
  if (opts.caFingerprint) {
@@ -125,7 +126,7 @@ function pinoElasticSearch(opts = {}) {
125
126
  const client = new Client(clientOpts)
126
127
  console.log("Logging to elasticsearch...");
127
128
  console.log("Any line showing up here means that the line was not logged to elasticsearch.");
128
- client.on('resurrect', () => {
129
+ client.diagnostic.on('resurrect', () => {
129
130
  initializeBulkHandler(opts, client, splitter)
130
131
  })
131
132
 
@@ -145,6 +146,7 @@ function start(opts) {
145
146
  console.error('Elasticsearch client error:', error)
146
147
  })
147
148
  stream.on('insertError', (error) => {
149
+ console.log(JSON.stringify(error))
148
150
  console.error('Elasticsearch server error:', error)
149
151
  })
150
152
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ditjenpajakri/elasticsearch-logging",
3
- "version": "1.1.0",
3
+ "version": "2.0.1",
4
4
  "description": "Elasticsearch ",
5
5
  "main": "lib.js",
6
6
  "bin": {
@@ -16,7 +16,7 @@
16
16
  },
17
17
  "license": "MIT",
18
18
  "dependencies": {
19
- "@elastic/elasticsearch": "^7.17.12",
19
+ "@elastic/elasticsearch": "8",
20
20
  "pump": "^3.0.0",
21
21
  "split2": "^4.2.0"
22
22
  },