Socket
Socket
Sign inDemoInstall

@google-cloud/profiler

Package Overview
Dependencies
Maintainers
1
Versions
54
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@google-cloud/profiler - npm Package Compare versions

Comparing version 4.1.5 to 4.1.6

2

build/src/config.d.ts

@@ -71,3 +71,3 @@ import { GoogleAuthOptions } from '@google-cloud/common';

initialBackoffMillis: number;
backoffCapMillis: number | null;
backoffCapMillis: number;
backoffMultiplier: number;

@@ -74,0 +74,0 @@ apiEndpoint: string;

@@ -200,3 +200,21 @@ "use strict";

const { rss, heapTotal, heapUsed } = process.memoryUsage();
logger.debug(new Date().toISOString(), 'rss', (rss / (1024 * 1024)).toFixed(3), 'MiB,', 'heap total', (heapTotal / (1024 * 1024)).toFixed(3), 'MiB,', 'heap used', (heapUsed / (1024 * 1024)).toFixed(3), 'MiB,', 'heap profile collection rate', ((heapProfileCount * 1000) / (curTime - prevLogTime)).toFixed(3), 'profiles/s,', 'time profile collection rate', ((timeProfileCount * 1000) / (curTime - prevLogTime)).toFixed(3), 'profiles/s');
const debugInfo = [
new Date().toISOString(),
'rss',
(rss / (1024 * 1024)).toFixed(3),
'MiB,',
'heap total',
(heapTotal / (1024 * 1024)).toFixed(3),
'MiB,',
'heap used',
(heapUsed / (1024 * 1024)).toFixed(3),
'MiB,',
'heap profile collection rate',
((heapProfileCount * 1000) / (curTime - prevLogTime)).toFixed(3),
'profiles/s,',
'time profile collection rate',
((timeProfileCount * 1000) / (curTime - prevLogTime)).toFixed(3),
'profiles/s',
].map(v => v + '');
logger.debug(debugInfo.join(' '));
heapProfileCount = 0;

@@ -203,0 +221,0 @@ timeProfileCount = 0;

@@ -1,2 +0,12 @@

import * as consoleLogLevel from 'console-log-level';
export declare function createLogger(level?: number): Record<consoleLogLevel.LogLevelNames, (...args: any[]) => void>;
export declare class Logger {
readonly level?: number | undefined;
private log;
private severityThreshold;
constructor(level?: number | undefined);
debug(msg: string): void;
info(msg: string): void;
warn(msg: string): void;
error(msg: string): void;
private toOneLine;
}
export declare function createLogger(level?: number): Logger;

@@ -16,35 +16,63 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.createLogger = void 0;
const consoleLogLevel = require("console-log-level");
exports.createLogger = exports.Logger = void 0;
/* eslint-disable @typescript-eslint/no-explicit-any */
const config_1 = require("./config");
const logging_min_1 = require("@google-cloud/logging-min");
const logging = new logging_min_1.Logging();
// migrating from 'console-log-level' package we keep
// min and max log levels numeric interface used there
const [MIN_LEVEL, MAX_LEVEL] = [0, 4];
logging.setProjectId().catch(err => {
console.error(`failed to set logging project id ${err}`);
});
logging.setDetectedResource().catch(err => {
console.error(`failed to discover resource metadata ${err}`);
});
// eslint-disable-next-line @typescript-eslint/no-var-requires
const pjson = require('../../package.json');
const LEVEL_NAMES = [
'fatal',
'error',
'warn',
'info',
'debug',
'trace',
];
function logLevelToName(level) {
if (level === undefined) {
level = config_1.defaultConfig.logLevel;
class Logger {
constructor(level) {
this.level = level;
if (level === undefined) {
level = config_1.defaultConfig.logLevel;
}
if (level < MIN_LEVEL) {
level = MIN_LEVEL;
}
else if (level > MAX_LEVEL) {
level = MAX_LEVEL;
}
this.severityThreshold = level;
this.log = logging.logSync(pjson.name);
}
else if (level < 0) {
level = 0;
debug(msg) {
if (this.severityThreshold > 3) {
this.log.debug(this.log.entry(this.toOneLine(msg)));
}
}
else if (level > 4) {
level = 4;
info(msg) {
if (this.severityThreshold > 2) {
this.log.info(this.log.entry(this.toOneLine(msg)));
}
}
return LEVEL_NAMES[level];
warn(msg) {
if (this.severityThreshold > 1) {
this.log.warning(this.log.entry(this.toOneLine(msg)));
}
}
error(msg) {
if (this.severityThreshold > 0) {
this.log.error(this.log.entry(this.toOneLine(msg)));
}
}
toOneLine(msg) {
const temp = msg.replace('\r\n', '\\r\\n');
return temp.replace('\n', '\\n');
}
}
exports.Logger = Logger;
function createLogger(level) {
return consoleLogLevel({
stderr: true,
prefix: pjson.name,
level: logLevelToName(level),
});
return new Logger(level);
}
exports.createLogger = createLogger;
//# sourceMappingURL=logger.js.map

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

### [4.1.6](https://www.github.com/googleapis/cloud-profiler-nodejs/compare/v4.1.5...v4.1.6) (2021-12-20)
### Bug Fixes
* log to console using structured logging ([#780](https://www.github.com/googleapis/cloud-profiler-nodejs/issues/780)) ([6b96e00](https://www.github.com/googleapis/cloud-profiler-nodejs/commit/6b96e007418bd6074c2bf9de64df0742e6a6d4ae))
### [4.1.5](https://www.github.com/googleapis/cloud-profiler-nodejs/compare/v4.1.4...v4.1.5) (2021-10-06)

@@ -9,0 +16,0 @@

{
"name": "@google-cloud/profiler",
"version": "4.1.5",
"version": "4.1.6",
"description": "Adds support for Cloud Profiler to Node.js applications",

@@ -32,2 +32,3 @@ "repository": "googleapis/cloud-profiler-nodejs",

"@google-cloud/common": "^3.0.0",
"@google-cloud/logging-min": "^9.6.3",
"@types/console-log-level": "^1.4.0",

@@ -51,6 +52,6 @@ "@types/semver": "^7.0.0",

"@types/nock": "^10.0.0",
"@types/node": "^14.0.0",
"@types/node": "^16.0.0",
"@types/pretty-ms": "^4.0.0",
"@types/sinon": "^10.0.0",
"@types/tmp": "0.2.1",
"@types/tmp": "0.2.3",
"c8": "^7.0.0",

@@ -66,3 +67,3 @@ "codecov": "^3.0.0",

"nock": "^13.0.0",
"sinon": "^11.0.0",
"sinon": "^12.0.0",
"source-map": "^0.7.0",

@@ -69,0 +70,0 @@ "tmp": "0.2.1",

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