Skip to content

Commit 59b038d

Browse files
authored
feat: Make log.meta optional (#16)
* Add check if msg and meta properties are deleted * Add fast check before deleting the property * Give log.meta priority in meta object and adjust tests * Add unit test for Should delete the msg and meta property * Make log.meta optional * Remove unnecessary Object.assign statement * Apply meta type check * Add unit tests covering empty strings
1 parent cd98cbc commit 59b038d

File tree

2 files changed

+413
-6
lines changed

2 files changed

+413
-6
lines changed

lib/cloud-logging.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,9 @@ class CloudLogging {
8080
return
8181
}
8282

83-
const meta = Object.assign(
84-
log.meta, // Custom property to add more meta to the LogEntry
85-
{ severity: this.mapSeverity(log.level) }
86-
)
83+
const meta = typeof (log.meta) === 'object'
84+
? Object.assign(log.meta, { severity: this.mapSeverity(log.level) })
85+
: { severity: this.mapSeverity(log.level) }
8786

8887
if (log.meta) {
8988
delete log.meta

0 commit comments

Comments
 (0)