azify-logger 1.0.53 → 1.0.54

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/package.json +4 -3
  2. package/server.js +35 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "azify-logger",
3
- "version": "1.0.53",
3
+ "version": "1.0.54",
4
4
  "description": "Azify Logger Client - Centralized logging for OpenSearch",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -50,7 +50,7 @@
50
50
  "@opentelemetry/sdk-trace-base": "1.25.0",
51
51
  "@opentelemetry/semantic-conventions": "1.25.0",
52
52
  "adm-zip": "^0.5.16",
53
- "archiver": "^6.0.1",
53
+ "archiver": "^4.0.2",
54
54
  "axios": "^1.7.9",
55
55
  "bull": "^4.16.5",
56
56
  "cors": "^2.8.5",
@@ -77,7 +77,8 @@
77
77
  "ioredis": "^5.8.2"
78
78
  },
79
79
  "overrides": {
80
- "semver": "^7.5.2"
80
+ "semver": "^7.5.2",
81
+ "glob": "^13.0.0"
81
82
  },
82
83
  "engines": {
83
84
  "node": ">=20 <=22"
package/server.js CHANGED
@@ -2053,7 +2053,7 @@ async function handleLog(req, res) {
2053
2053
 
2054
2054
  res.json({ success: true, message: 'Log enviado com sucesso', index: indexName })
2055
2055
 
2056
- const docToSend = _trimLogEntryForOpenSearch(logEntry)
2056
+ const docToSend = _normalizeLogEntryForOpenSearch(_trimLogEntryForOpenSearch(logEntry))
2057
2057
  _enqueueOpenSearchWrite(osUrl, indexName, docToSend, serviceName)
2058
2058
  }
2059
2059
 
@@ -2106,6 +2106,40 @@ function _trimLogEntryForOpenSearch(doc) {
2106
2106
  return out
2107
2107
  }
2108
2108
 
2109
+ function _normalizeLogEntryForOpenSearch(doc) {
2110
+ if (!doc || typeof doc !== 'object') return doc
2111
+ function coerceToString(v) {
2112
+ if (v == null) return v
2113
+ if (typeof v === 'string') return v
2114
+ if (Buffer.isBuffer(v)) return v.toString('utf8')
2115
+ if (typeof v === 'object') {
2116
+ try {
2117
+ return JSON.stringify(v)
2118
+ } catch (_) {
2119
+ return String(v)
2120
+ }
2121
+ }
2122
+ return String(v)
2123
+ }
2124
+ function normalizeNested(obj) {
2125
+ if (!obj || typeof obj !== 'object' || Buffer.isBuffer(obj)) return obj
2126
+ const o = { ...obj }
2127
+ for (const k of ['responseBody', 'requestBody']) {
2128
+ if (o[k] != null && typeof o[k] !== 'string') o[k] = coerceToString(o[k])
2129
+ }
2130
+ if (o.body != null && typeof o.body === 'object' && !Buffer.isBuffer(o.body)) {
2131
+ o.bodyJson = coerceToString(o.body)
2132
+ delete o.body
2133
+ }
2134
+ return o
2135
+ }
2136
+ const out = normalizeNested(doc)
2137
+ if (out.meta != null && typeof out.meta === 'object') {
2138
+ out.meta = normalizeNested(out.meta)
2139
+ }
2140
+ return out
2141
+ }
2142
+
2109
2143
  const _openSearchWriteQueue = []
2110
2144
  let _openSearchWriteInFlight = 0
2111
2145
  const _openSearchWriteMaxConcurrent = 10