@google-cloud/logging
Advanced tools
Comparing version 8.0.10 to 8.1.0
@@ -18,3 +18,3 @@ /*! | ||
import { google } from '../protos/protos'; | ||
export declare type Timestamp = google.protobuf.ITimestamp | Date; | ||
export declare type Timestamp = google.protobuf.ITimestamp | Date | string; | ||
export declare type LogSeverity = google.logging.type.LogSeverity | string; | ||
@@ -21,0 +21,0 @@ export declare type LogEntry = Merge<google.logging.v2.ILogEntry, { |
@@ -123,3 +123,5 @@ "use strict"; | ||
toJSON(options = {}) { | ||
var _a; | ||
const entry = extend(true, {}, this.metadata); | ||
// Format log message | ||
if (is.object(this.data)) { | ||
@@ -134,2 +136,3 @@ entry.jsonPayload = common_1.objToStruct(this.data, { | ||
} | ||
// Format log timestamp | ||
if (is.date(entry.timestamp)) { | ||
@@ -143,2 +146,13 @@ const seconds = entry.timestamp.getTime() / 1000; | ||
} | ||
else if (is.string(entry.timestamp)) { | ||
// Convert RFC3339 "Zulu" timestamp into a format that can be parsed to Date | ||
const zuluTime = entry.timestamp; | ||
const ms = Date.parse(zuluTime.split(/[.,Z]/)[0] + 'Z'); | ||
const reNano = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.(\d{0,9})Z$/; | ||
const nanoSecs = (_a = zuluTime.match(reNano)) === null || _a === void 0 ? void 0 : _a[1]; | ||
entry.timestamp = { | ||
seconds: ms ? Math.floor(ms / 1000) : 0, | ||
nanos: nanoSecs ? Number(nanoSecs.padEnd(9, '0')) : 0, | ||
}; | ||
} | ||
return entry; | ||
@@ -145,0 +159,0 @@ } |
@@ -7,2 +7,14 @@ # Changelog | ||
## [8.1.0](https://www.github.com/googleapis/nodejs-logging/compare/v8.0.10...v8.1.0) (2020-11-09) | ||
### Features | ||
* accept entry.timestamp string input in RFC3339 format ([#937](https://www.github.com/googleapis/nodejs-logging/issues/937)) ([869bbaf](https://www.github.com/googleapis/nodejs-logging/commit/869bbafe3790d6d6f21a1f538549a1f336d6f918)) | ||
### Bug Fixes | ||
* **deps:** roll back dependency @google-cloud/logging to ^8.0.9 ([#940](https://www.github.com/googleapis/nodejs-logging/issues/940)) ([2a3ad40](https://www.github.com/googleapis/nodejs-logging/commit/2a3ad405683421f5d2099da1b658fe111dc336d2)) | ||
### [8.0.10](https://www.github.com/googleapis/nodejs-logging/compare/v8.0.9...v8.0.10) (2020-11-06) | ||
@@ -9,0 +21,0 @@ |
{ | ||
"name": "@google-cloud/logging", | ||
"version": "8.0.10", | ||
"version": "8.1.0", | ||
"description": "Stackdriver Logging Client Library for Node.js", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3050552
51326