New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@squiz/component-logger-lib

Package Overview
Dependencies
Maintainers
44
Versions
327
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@squiz/component-logger-lib - npm Package Compare versions

Comparing version

to
1.35.1-alpha.6

.npm/_logs/2023-06-05T01_50_15_795Z-debug-0.log

13

lib/component-logger.js

@@ -38,4 +38,5 @@ "use strict";

async append(level, message, traceId) {
var _a;
const payload = typeof message == 'string' ? message : JSON.stringify(message);
this.batch.push({
let logMessage = {
level: level,

@@ -45,5 +46,11 @@ service: 'render-runtime',

message: payload,
tags: this.config.tags,
traceid: traceId,
});
};
if ((_a = this.config.tags) === null || _a === void 0 ? void 0 : _a.length) {
logMessage = {
...logMessage,
tags: this.config.tags,
};
}
this.batch.push(logMessage);
if (this.batch.length == MESSAGE_BATCH_SIZE) {

@@ -50,0 +57,0 @@ await this.flush();

@@ -92,2 +92,45 @@ "use strict";

});
it('should not include "tags" in payload if tags is not configured', async () => {
const loggerConfig = {
enabled: true,
logUrl: 'some-log-url/',
key: 'some-key',
tenantId: 'some-tenant-id',
};
const logger = new component_logger_1.ComponentLogger(loggerConfig);
await logger.info('The quick brown fox', '123');
await logger.flush();
const expectedMessages = [
{
level: 'INFO',
service: 'render-runtime',
timestamp: '2023-05-28T00:00:00.000Z',
message: 'The quick brown fox',
traceid: '123',
},
];
expect(postSetMock.send).toBeCalledWith(expectedMessages);
});
it('should not include "tags" in payload if tags is configured as empty string', async () => {
const loggerConfig = {
enabled: true,
logUrl: 'some-log-url/',
key: 'some-key',
tenantId: 'some-tenant-id',
tags: '',
};
const logger = new component_logger_1.ComponentLogger(loggerConfig);
await logger.info('The quick brown fox', '123');
await logger.flush();
const expectedMessages = [
{
level: 'INFO',
service: 'render-runtime',
timestamp: '2023-05-28T00:00:00.000Z',
message: 'The quick brown fox',
traceid: '123',
},
];
expect(postSetMock.send).toBeCalledWith(expectedMessages);
});
it('should not send message if disabled', async () => {

@@ -94,0 +137,0 @@ const loggerConfig = {

{
"name": "@squiz/component-logger-lib",
"version": "1.35.1-alpha.5",
"version": "1.35.1-alpha.6",
"description": "",

@@ -24,3 +24,3 @@ "main": "lib/index.js",

},
"gitHead": "6c976023e77f7cceab962b5563fcaf669aedaa6d"
"gitHead": "59c19bcba89607f7909e83d5d9f6895841870a3a"
}

@@ -104,2 +104,53 @@ import { ComponentLogger } from './component-logger';

it('should not include "tags" in payload if tags is not configured', async () => {
const loggerConfig = <ComponentLoggerConfig>{
enabled: true,
logUrl: 'some-log-url/',
key: 'some-key',
tenantId: 'some-tenant-id',
};
const logger = new ComponentLogger(loggerConfig);
await logger.info('The quick brown fox', '123');
await logger.flush();
const expectedMessages = [
{
level: 'INFO',
service: 'render-runtime',
timestamp: '2023-05-28T00:00:00.000Z',
message: 'The quick brown fox',
traceid: '123',
},
];
expect(postSetMock.send).toBeCalledWith(expectedMessages);
});
it('should not include "tags" in payload if tags is configured as empty string', async () => {
const loggerConfig = <ComponentLoggerConfig>{
enabled: true,
logUrl: 'some-log-url/',
key: 'some-key',
tenantId: 'some-tenant-id',
tags: '',
};
const logger = new ComponentLogger(loggerConfig);
await logger.info('The quick brown fox', '123');
await logger.flush();
const expectedMessages = [
{
level: 'INFO',
service: 'render-runtime',
timestamp: '2023-05-28T00:00:00.000Z',
message: 'The quick brown fox',
traceid: '123',
},
];
expect(postSetMock.send).toBeCalledWith(expectedMessages);
});
it('should not send message if disabled', async () => {

@@ -106,0 +157,0 @@ const loggerConfig = <ComponentLoggerConfig>{

@@ -42,4 +42,3 @@ import superagent from 'superagent';

const payload = typeof message == 'string' ? message : JSON.stringify(message);
this.batch.push({
let logMessage: ComponentLogMessage = {
level: level,

@@ -49,5 +48,11 @@ service: 'render-runtime',

message: payload,
tags: this.config.tags,
traceid: traceId,
});
};
if (this.config.tags?.length) {
logMessage = {
...logMessage,
tags: this.config.tags,
};
}
this.batch.push(logMessage);

@@ -54,0 +59,0 @@ if (this.batch.length == MESSAGE_BATCH_SIZE) {

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