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

@contrast/logger

Package Overview
Dependencies
Maintainers
9
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@contrast/logger - npm Package Compare versions

Comparing version 1.6.0 to 1.7.0

41

lib/index.js

@@ -46,2 +46,4 @@ "use strict";

const common_1 = require("@contrast/common");
const fs_1 = __importDefault(require("fs"));
const path_1 = __importDefault(require("path"));
const pino_1 = __importDefault(require("pino"));

@@ -59,13 +61,24 @@ const serializers = __importStar(require("./serializers"));

const config = core.config.agent.logger;
const targets = [
{
target: 'pino/file',
level: 'trace',
options: {
append: config.append,
destination: config.path,
mkdir: true,
},
},
];
const targets = [];
let err;
if (config.path !== '/dev/null') {
try {
// fs methods throw if we don't have write permissions.
fs_1.default.mkdirSync(path_1.default.dirname(config.path), { recursive: true });
fs_1.default.openSync(config.path, config.append ? 'a' : 'w');
targets.push({
target: 'pino/file',
level: 'trace',
options: {
append: config.append,
destination: config.path,
},
});
}
catch (cause) {
err = new Error('Unable to write to the configured log file. To disable writing to a log file, set `agent.logger.path` to \'/dev/null\', or set CONTRAST__AGENT__LOGGER__PATH="/dev/null" in your environment',
// @ts-expect-error `cause` requires ts to target es2022 or above, which corresponds to Node 17+, despite being added to Node in 16.9
{ cause });
}
}
if (config.stdout) {

@@ -78,2 +91,4 @@ targets.push({

}
if (err && targets.length === 0)
throw err;
const logger = core.logger = extend((0, pino_1.default)({

@@ -106,5 +121,7 @@ name: 'contrast',

}
return core.logger;
if (err)
logger.error({ err });
return logger;
}
exports.default = init;
//# sourceMappingURL=index.js.map

@@ -78,2 +78,6 @@ import { Config } from '@contrast/config';

};
metrics: {
enable: boolean;
warn_ms: number;
};
};

@@ -131,2 +135,4 @@ };

export declare const err: (err: Error) => Record<string, any>;
/** Excludes irrelevant information from the metrics object. */
export declare function metrics({ start, timeout, ...metrics }: any): any;
/**

@@ -133,0 +139,0 @@ * Serializes requests for the contrast-ui http logger.

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

Object.defineProperty(exports, "__esModule", { value: true });
exports.res = exports.req = exports.err = exports.config = void 0;
exports.res = exports.req = exports.metrics = exports.err = exports.config = void 0;
const pino_1 = require("pino");

@@ -33,2 +33,7 @@ /**

exports.err = pino_1.stdSerializers.wrapErrorSerializer(({ stdout, stderr, ...err }) => err);
/** Excludes irrelevant information from the metrics object. */
function metrics({ start, timeout, ...metrics }) {
return metrics;
}
exports.metrics = metrics;
/**

@@ -35,0 +40,0 @@ * Serializes requests for the contrast-ui http logger.

{
"name": "@contrast/logger",
"version": "1.6.0",
"version": "1.7.0",
"description": "Centralized logging for Contrast agent services",

@@ -5,0 +5,0 @@ "license": "SEE LICENSE IN LICENSE",

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

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