@contrast/logger
Advanced tools
Comparing version 1.4.0 to 1.4.1
import { Config } from '@contrast/config'; | ||
import { Logger } from 'pino'; | ||
export { Logger }; | ||
interface Core { | ||
import { Messages } from '@contrast/common'; | ||
import { LoggerOptions, Logger as PinoLogger, TransportTargetOptions } from 'pino'; | ||
export interface Core { | ||
readonly config: Config; | ||
readonly messages: Messages; | ||
} | ||
export default function init(core: Core): Logger; | ||
export declare const kChildren: unique symbol; | ||
export declare const kTransports: unique symbol; | ||
export interface Logger extends PinoLogger { | ||
[kChildren]: Logger[]; | ||
[kTransports]: TransportTargetOptions[]; | ||
} | ||
export default function init(core: Core & { | ||
logger?: Logger; | ||
}, opts?: LoggerOptions): Logger; | ||
//# sourceMappingURL=index.d.ts.map |
"use strict"; | ||
/* | ||
* Copyright: 2022 Contrast Security, Inc | ||
* Copyright: 2023 Contrast Security, Inc | ||
* Contact: support@contrastsecurity.com | ||
@@ -16,2 +16,25 @@ * License: Commercial | ||
*/ | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
@@ -21,5 +44,15 @@ return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.kTransports = exports.kChildren = void 0; | ||
const common_1 = require("@contrast/common"); | ||
const pino_1 = __importDefault(require("pino")); | ||
const serializers = __importStar(require("./serializers")); | ||
const utils_1 = require("./utils"); | ||
function init(core) { | ||
exports.kChildren = Symbol('contrast.logger.children'); | ||
exports.kTransports = Symbol('contrast.logger.transports'); | ||
function extend(logger, targets) { | ||
Reflect.set(logger, exports.kChildren, []); | ||
Reflect.set(logger, exports.kTransports, targets); | ||
return logger; | ||
} | ||
function init(core, opts = {}) { | ||
const config = core.config.agent.logger; | ||
@@ -44,3 +77,3 @@ const targets = [ | ||
} | ||
return (0, pino_1.default)({ | ||
const logger = core.logger = extend((0, pino_1.default)({ | ||
name: 'contrast', | ||
@@ -56,10 +89,25 @@ level: 'trace', | ||
...pino_1.default.stdSerializers, | ||
/* c8 ignore next 3 */ | ||
config({ _default, _flat, _sources, ...rest }) { | ||
return rest; | ||
}, | ||
...serializers, | ||
}, | ||
onChild(instance) { | ||
this[exports.kChildren].push(extend(instance, targets)); | ||
}, | ||
...opts, | ||
}), targets); | ||
logger.on('level-change', (level, val, prevLevel, prevVal, instance) => { | ||
instance[exports.kChildren].forEach(child => child.level = level); | ||
}); | ||
logger.level = config.level ?? 'info'; | ||
if (!config.level) { | ||
core.messages.on(common_1.Event.SERVER_SETTINGS_UPDATE, (msg) => { | ||
const tsLevel = msg?.logger?.level?.toLowerCase(); | ||
if (tsLevel && tsLevel !== logger.level) { | ||
logger.level = tsLevel; | ||
logger.info('Received new log level: %s from server-features', tsLevel); | ||
} | ||
}); | ||
} | ||
return core.logger; | ||
} | ||
exports.default = init; | ||
//# sourceMappingURL=index.js.map |
"use strict"; | ||
/* | ||
* Copyright: 2022 Contrast Security, Inc | ||
* Copyright: 2023 Contrast Security, Inc | ||
* Contact: support@contrastsecurity.com | ||
@@ -5,0 +5,0 @@ * License: Commercial |
{ | ||
"name": "@contrast/logger", | ||
"version": "1.4.0", | ||
"version": "1.4.1", | ||
"description": "Centralized logging for Contrast agent services", | ||
@@ -21,4 +21,4 @@ "license": "SEE LICENSE IN LICENSE", | ||
"dependencies": { | ||
"pino": "^7.10.0" | ||
"pino": "^8.15.0" | ||
} | ||
} |
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
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
23943
15
292
1
+ Addedabort-controller@3.0.0(transitive)
+ Addedbase64-js@1.5.1(transitive)
+ Addedbuffer@6.0.3(transitive)
+ Addedevent-target-shim@5.0.1(transitive)
+ Addedevents@3.3.0(transitive)
+ Addedieee754@1.2.1(transitive)
+ Addedon-exit-leak-free@2.1.2(transitive)
+ Addedpino@8.21.0(transitive)
+ Addedpino-abstract-transport@1.2.0(transitive)
+ Addedpino-std-serializers@6.2.2(transitive)
+ Addedprocess@0.11.10(transitive)
+ Addedprocess-warning@3.0.0(transitive)
+ Addedreadable-stream@4.5.2(transitive)
+ Addedreal-require@0.2.0(transitive)
+ Addedsafe-buffer@5.2.1(transitive)
+ Addedsonic-boom@3.8.1(transitive)
+ Addedsplit2@4.2.0(transitive)
+ Addedstring_decoder@1.3.0(transitive)
+ Addedthread-stream@2.7.0(transitive)
- Removedon-exit-leak-free@0.2.0(transitive)
- Removedpino@7.11.0(transitive)
- Removedpino-std-serializers@4.0.0(transitive)
- Removedprocess-warning@1.0.0(transitive)
- Removedreal-require@0.1.0(transitive)
- Removedsonic-boom@2.8.0(transitive)
- Removedthread-stream@0.15.2(transitive)
Updatedpino@^8.15.0