Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@google-cloud/logging

Package Overview
Dependencies
Maintainers
1
Versions
157
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@google-cloud/logging - npm Package Compare versions

Comparing version 9.1.1 to 9.2.0

29

build/src/common.js

@@ -19,3 +19,2 @@ "use strict";

exports.decodeValue = exports.structToObj = exports.ObjectToStructConverter = exports.objToStruct = void 0;
const is = require("is");
function objToStruct(obj, options) {

@@ -72,3 +71,3 @@ return new ObjectToStructConverter(options).convert(obj);

const value = obj[prop];
if (is.undefined(value)) {
if (value === undefined) {
continue;

@@ -100,3 +99,3 @@ }

let convertedValue;
if (is.null(value)) {
if (value === null) {
convertedValue = {

@@ -106,3 +105,3 @@ nullValue: 0,

}
else if (is.number(value)) {
else if (typeof value === 'number') {
convertedValue = {

@@ -112,3 +111,3 @@ numberValue: value,

}
else if (is.string(value)) {
else if (typeof value === 'string') {
convertedValue = {

@@ -118,3 +117,3 @@ stringValue: value,

}
else if (is.boolean(value)) {
else if (typeof value === 'boolean') {
convertedValue = {

@@ -129,3 +128,12 @@ boolValue: value,

}
else if (is.object(value)) {
else if (Array.isArray(value)) {
convertedValue = {
listValue: {
values: value.map(this.encodeValue_.bind(this)),
},
};
}
else if ((value === null || value === void 0 ? void 0 : value.toString()) === '[object Object]') {
// Using `typeof value === 'object'` is discouraged here, because it
// return true for dates, nulls, arrays, etc.
if (this.seenObjects.has(value)) {

@@ -149,9 +157,2 @@ // Circular reference.

}
else if (is.array(value)) {
convertedValue = {
listValue: {
values: value.map(this.encodeValue_.bind(this)),
},
};
}
else {

@@ -158,0 +159,0 @@ if (!this.stringify) {

@@ -16,10 +16,9 @@ /*!

*/
import { Merge } from 'type-fest';
import { google } from '../protos/protos';
export declare type Timestamp = google.protobuf.ITimestamp | Date | string;
export declare type LogSeverity = google.logging.type.LogSeverity | string;
export declare type LogEntry = Merge<google.logging.v2.ILogEntry, {
export declare type LogEntry = Omit<google.logging.v2.ILogEntry, 'timestamp' | 'severity'> & {
timestamp?: Timestamp | null;
severity?: LogSeverity | null;
}>;
};
export declare type Data = any;

@@ -26,0 +25,0 @@ export interface EntryJson {

@@ -22,3 +22,2 @@ "use strict";

const extend = require("extend");
const is = require("is");
const common_1 = require("./common");

@@ -124,6 +123,6 @@ const eventId = new EventId();

toJSON(options = {}) {
var _a;
var _a, _b;
const entry = extend(true, {}, this.metadata);
// Format log message
if (is.object(this.data)) {
if (((_a = this.data) === null || _a === void 0 ? void 0 : _a.toString()) === '[object Object]') {
entry.jsonPayload = common_1.objToStruct(this.data, {

@@ -134,7 +133,7 @@ removeCircular: !!options.removeCircular,

}
else if (is.string(this.data)) {
else if (typeof this.data === 'string') {
entry.textPayload = this.data;
}
// Format log timestamp
if (is.date(entry.timestamp)) {
if (entry.timestamp instanceof Date) {
const seconds = entry.timestamp.getTime() / 1000;

@@ -147,3 +146,3 @@ const secondsRounded = Math.floor(seconds);

}
else if (is.string(entry.timestamp)) {
else if (typeof entry.timestamp === 'string') {
// Convert RFC3339 "Zulu" timestamp into a format that can be parsed to Date

@@ -153,3 +152,3 @@ const zuluTime = entry.timestamp;

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];
const nanoSecs = (_b = zuluTime.match(reNano)) === null || _b === void 0 ? void 0 : _b[1];
entry.timestamp = {

@@ -156,0 +155,0 @@ seconds: ms ? Math.floor(ms / 1000) : 0,

@@ -31,2 +31,16 @@ /*!

/**
* Create a descriptor for Cloud Run.
*
* @returns {object}
*/
export declare function getCloudRunDescriptor(): Promise<{
type: string;
labels: {
location: string | undefined;
service_name: string | undefined;
revision_name: string | undefined;
configuration_name: string | undefined;
};
}>;
/**
* Create a descriptor for Google App Engine.

@@ -33,0 +47,0 @@ *

@@ -18,3 +18,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.detectServiceContext = exports.getDefaultResource = exports.getGlobalDescriptor = exports.getGKEDescriptor = exports.KUBERNETES_NAMESPACE_ID_PATH = exports.getGCEDescriptor = exports.getGAEDescriptor = exports.getCloudFunctionDescriptor = void 0;
exports.detectServiceContext = exports.getDefaultResource = exports.getGlobalDescriptor = exports.getGKEDescriptor = exports.KUBERNETES_NAMESPACE_ID_PATH = exports.getGCEDescriptor = exports.getGAEDescriptor = exports.getCloudRunDescriptor = exports.getCloudFunctionDescriptor = void 0;
const fs = require("fs");

@@ -53,2 +53,21 @@ const gcpMetadata = require("gcp-metadata");

/**
* Create a descriptor for Cloud Run.
*
* @returns {object}
*/
async function getCloudRunDescriptor() {
const qualifiedZone = await gcpMetadata.instance('zone');
const location = zoneFromQualifiedZone(qualifiedZone);
return {
type: 'cloud_run_revision',
labels: {
location,
service_name: process.env.K_SERVICE,
revision_name: process.env.K_REVISION,
configuration_name: process.env.K_CONFIGURATION,
},
};
}
exports.getCloudRunDescriptor = getCloudRunDescriptor;
/**
* Create a descriptor for Google App Engine.

@@ -151,5 +170,11 @@ *

case google_auth_library_1.GCPEnv.COMPUTE_ENGINE:
// Test for compute engine should be done after all the rest -
// everything runs on top of compute engine.
return getGCEDescriptor().catch(() => getGlobalDescriptor());
// Google Cloud Run
if (process.env.K_CONFIGURATION) {
return getCloudRunDescriptor().catch(() => getGlobalDescriptor());
}
else {
// Test for compute engine should be done after all the rest -
// everything runs on top of compute engine.
return getGCEDescriptor().catch(() => getGlobalDescriptor());
}
default:

@@ -185,2 +210,9 @@ return getGlobalDescriptor();

case google_auth_library_1.GCPEnv.COMPUTE_ENGINE:
// Google Cloud Run
if (process.env.K_CONFIGURATION) {
return {
service: process.env.K_SERVICE,
};
}
return null;
default:

@@ -187,0 +219,0 @@ return null;

@@ -7,2 +7,15 @@ # Changelog

## [9.2.0](https://www.github.com/googleapis/nodejs-logging/compare/v9.1.1...v9.2.0) (2021-04-05)
### Features
* resource autodetection for cloud run ([#1024](https://www.github.com/googleapis/nodejs-logging/issues/1024)) ([08c4404](https://www.github.com/googleapis/nodejs-logging/commit/08c4404fa401f0d90a8ee24a5b0477777e6b5e70))
### Bug Fixes
* **deps:** drop dependency on is ([#1021](https://www.github.com/googleapis/nodejs-logging/issues/1021)) ([f32da13](https://www.github.com/googleapis/nodejs-logging/commit/f32da13ac6744de68a6d8e2d615df2bb80438643))
* **deps:** drop dependency on type-fest ([#1020](https://www.github.com/googleapis/nodejs-logging/issues/1020)) ([f1e35e4](https://www.github.com/googleapis/nodejs-logging/commit/f1e35e443e04d832677eca8663fb3ae2567919fa))
### [9.1.1](https://www.github.com/googleapis/nodejs-logging/compare/v9.1.0...v9.1.1) (2021-03-31)

@@ -9,0 +22,0 @@

{
"name": "@google-cloud/logging",
"version": "9.1.1",
"version": "9.2.0",
"description": "Stackdriver Logging Client Library for Node.js",

@@ -61,3 +61,2 @@ "keywords": [

"google-gax": "^2.9.2",
"is": "^3.3.0",
"on-finished": "^2.3.0",

@@ -67,4 +66,3 @@ "pumpify": "^2.0.1",

"stream-events": "^1.0.5",
"through2": "^4.0.0",
"type-fest": "^0.21.0"
"through2": "^4.0.0"
},

@@ -76,3 +74,2 @@ "devDependencies": {

"@types/extend": "^3.0.1",
"@types/is": "0.0.21",
"@types/mocha": "^8.0.0",

@@ -106,3 +103,3 @@ "@types/mv": "^2.1.0",

"proxyquire": "^2.1.3",
"sinon": "^9.0.1",
"sinon": "^10.0.0",
"ts-loader": "^8.0.0",

@@ -109,0 +106,0 @@ "typescript": "^3.8.3",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc