@ditjenpajakri/elasticsearch-logging 2.2.0 → 2.2.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 (3) hide show
  1. package/apm.env +1 -1
  2. package/lib.js +9 -19
  3. package/package.json +1 -1
package/apm.env CHANGED
@@ -3,4 +3,4 @@ LOG_ES_PASS=jkljkl2020
3
3
  LOG_ES_VAR_A_AA=aaa
4
4
  LOG_ES_VAR_A_BB=bbb
5
5
  LOG_ES_VAR_B=ccc
6
- LOG_ES_INDEX=test-index-%{DATE}
6
+ LOG_ES_INDEX=test-a-%{DATE}
package/lib.js CHANGED
@@ -51,7 +51,7 @@ function initializeBulkHandler(opts, client, splitter) {
51
51
  const esVersion = Number(opts.esVersion || opts["es-version"]) || 7;
52
52
  const index = opts.index || "pino";
53
53
  const buildIndexName = typeof index === "function" ? index : null;
54
- // const type = esVersion >= 7 ? undefined : opts.type || "log";
54
+ // const type = esVersion >= 7 ? undefined : opts.type || "log";
55
55
  const opType = esVersion >= 7 ? opts.opType || opts.op_type : undefined;
56
56
 
57
57
  // Resurrect connection pool on destroy
@@ -210,28 +210,18 @@ if (require.main === module) {
210
210
 
211
211
  const additionalFields = Object.keys(process.env).filter((key) =>
212
212
  key.startsWith("LOG_ES_VAR_")
213
- ).map(s => s.toLowerCase())
214
-
215
- const additionalObject = additionalFields.reduce((obj, field) => {
216
- const value = process.env[field.toLocaleUpperCase()];
217
- function processKey(f, value) {
218
- const parts = f ? f.split("_") : [];
219
- if (parts.length) {
220
- return processKey(parts.slice(0, parts.length - 1).join("_"), {
221
- [parts[parts.length - 1]]: value,
222
- });
223
- } else {
224
- if (f) return { [f]: value };
225
- else return value;
226
- }
227
- }
213
+ );
228
214
 
229
- return mergeDeep(obj, processKey(field, value));
230
- }, {});
215
+ const additionalObject = {};
216
+ additionalFields.forEach((field) => {
217
+ const value = process.env[field];
218
+ const key = field.slice(11);
219
+ additionalObject[key] = value;
220
+ });
231
221
 
232
222
  start({
233
223
  node: process.env.LOG_ES_HOST || "http://localhost:9200",
234
- additionalObject: additionalObject?.log?.es?.var ? additionalObject.log.es.var : {},
224
+ additionalObject,
235
225
  auth: {
236
226
  username: process.env.LOG_ES_USER || "elastic",
237
227
  password: process.env.LOG_ES_PASS || "changeme",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ditjenpajakri/elasticsearch-logging",
3
- "version": "2.2.0",
3
+ "version": "2.2.1",
4
4
  "description": "Elasticsearch ",
5
5
  "main": "lib.js",
6
6
  "bin": {