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

@furystack/logging

Package Overview
Dependencies
Maintainers
1
Versions
146
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@furystack/logging - npm Package Compare versions

Comparing version 6.0.0 to 6.0.1

111

esm/logger.spec.js

@@ -8,3 +8,3 @@ import { using } from '@furystack/utils';

import { TestLogger } from './test-logger.js';
import { describe, it, expect, vi } from 'vitest';
import { describe, it, expect, vi, afterAll, beforeEach } from 'vitest';
describe('Loggers', () => {

@@ -137,23 +137,92 @@ it('Can be set up and retrieved with a helper', () => {

});
describe('Scoped Logger', () => {
const scopedConsoleLogger = new ConsoleLogger().withScope('scope');
it('Should print with addEntry', () => scopedConsoleLogger.addEntry({ message: 'Example Verbose Message', level: LogLevel.Verbose }));
it('Should print Verbose', () => scopedConsoleLogger.verbose({ message: 'Example Verbose Message' }));
it('Should print Debug', () => scopedConsoleLogger.debug({ message: 'Example Debug Message' }));
it('Should print Information', () => scopedConsoleLogger.information({ message: 'Example Information Message' }));
it('Should print Warning', () => scopedConsoleLogger.warning({ message: 'Example Warning Message' }));
it('Should print Error', () => scopedConsoleLogger.error({ message: 'Example Error Message' }));
it('Should print Fatal', () => scopedConsoleLogger.fatal({ message: 'Example Fatal Message' }));
it('Should print additional data', () => scopedConsoleLogger.fatal({ message: 'Example Fatal Message', data: { a: 1 } }));
describe('Console Logger', () => {
const scope = 'exampleScope';
const scopedConsoleLogger = new ConsoleLogger().withScope(scope);
const consoleMock = vi.spyOn(console, 'log').mockImplementation(() => { });
afterAll(() => {
consoleMock.mockRestore();
});
beforeEach(() => {
consoleMock.mockReset();
});
describe('With scope', () => {
it('Should print with addEntry', async () => {
const message = { message: 'Example Verbose Message', level: LogLevel.Verbose };
await scopedConsoleLogger.addEntry(message);
expect(consoleMock).toHaveBeenCalledWith(...defaultFormat({ ...message, scope }));
});
it('Should print Verbose', async () => {
const message = { message: 'Example Verbose Message' };
await scopedConsoleLogger.verbose(message);
expect(consoleMock).toHaveBeenCalledWith(...defaultFormat({ ...message, level: LogLevel.Verbose, scope }));
});
it('Should print Debug', async () => {
const message = { message: 'Example Debug Message' };
await scopedConsoleLogger.debug(message);
expect(consoleMock).toHaveBeenCalledWith(...defaultFormat({ ...message, level: LogLevel.Debug, scope }));
});
it('Should print Information', async () => {
const message = { message: 'Example Information Message' };
await scopedConsoleLogger.information(message);
expect(consoleMock).toHaveBeenCalledWith(...defaultFormat({ ...message, level: LogLevel.Information, scope }));
});
it('Should print Warning', async () => {
const message = { message: 'Example Warning Message' };
await scopedConsoleLogger.warning(message);
expect(consoleMock).toHaveBeenCalledWith(...defaultFormat({ ...message, level: LogLevel.Warning, scope }));
});
it('Should print Error', async () => {
const message = { message: 'Example Error Message' };
await scopedConsoleLogger.error(message);
expect(consoleMock).toHaveBeenCalledWith(...defaultFormat({ ...message, level: LogLevel.Error, scope }));
});
it('Should print Fatal', async () => {
const message = { message: 'Example Fatal Message' };
await scopedConsoleLogger.fatal(message);
expect(consoleMock).toHaveBeenCalledWith(...defaultFormat({ ...message, level: LogLevel.Fatal, scope }));
});
it('Should print additional data', async () => {
const message = { message: 'Example Fatal Message', data: { a: 1 } };
await scopedConsoleLogger.fatal(message);
expect(consoleMock).toHaveBeenCalledWith(...defaultFormat({ ...message, level: LogLevel.Fatal, scope, data: { a: 1 } }));
});
});
describe('Without scope', () => {
const consoleLogger = new ConsoleLogger();
it('Should print Verbose', async () => {
const message = { message: 'Example Verbose Message', scope };
await consoleLogger.verbose(message);
expect(consoleMock).toHaveBeenCalledWith(...defaultFormat({ ...message, level: LogLevel.Verbose }));
});
it('Should print Debug', async () => {
const message = { message: 'Example Debug Message', scope };
await consoleLogger.debug(message);
expect(consoleMock).toHaveBeenCalledWith(...defaultFormat({ ...message, level: LogLevel.Debug }));
});
it('Should print Information', async () => {
const message = { message: 'Example Information Message', scope };
await consoleLogger.information(message);
});
it('Should print Warning', async () => {
const message = { message: 'Example Warning Message', scope };
await consoleLogger.warning(message);
expect(consoleMock).toHaveBeenCalledWith(...defaultFormat({ ...message, level: LogLevel.Warning }));
});
it('Should print Error', async () => {
const message = { message: 'Example Error Message', scope };
await consoleLogger.error(message);
expect(consoleMock).toHaveBeenCalledWith(...defaultFormat({ ...message, level: LogLevel.Error }));
});
it('Should print Fatal', async () => {
const message = { message: 'Example Fatal Message', scope };
consoleLogger.fatal(message);
expect(consoleMock).toHaveBeenCalledWith(...defaultFormat({ ...message, level: LogLevel.Fatal }));
});
it('Should print additional data', async () => {
const message = { message: 'Example Fatal Message', data: { a: 1 }, scope };
consoleLogger.fatal(message);
expect(consoleMock).toHaveBeenCalledWith(...defaultFormat({ ...message, level: LogLevel.Fatal }));
});
});
});
describe('ConsoleLogger', () => {
const consoleLogger = new ConsoleLogger();
it('Should print Verbose', () => consoleLogger.verbose({ scope: 'scope', message: 'Example Verbose Message' }));
it('Should print Debug', () => consoleLogger.debug({ scope: 'scope', message: 'Example Debug Message' }));
it('Should print Information', () => consoleLogger.information({ scope: 'scope', message: 'Example Information Message' }));
it('Should print Warning', () => consoleLogger.warning({ scope: 'scope', message: 'Example Warning Message' }));
it('Should print Error', () => consoleLogger.error({ scope: 'scope', message: 'Example Error Message' }));
it('Should print Fatal', () => consoleLogger.fatal({ scope: 'scope', message: 'Example Fatal Message' }));
it('Should print additional data', () => consoleLogger.fatal({ scope: 'scope', message: 'Example Fatal Message', data: { a: 1 } }));
});
describe('defaultFormatter', () => {

@@ -160,0 +229,0 @@ it('Should print compact messages', () => expect(defaultFormat({

8

package.json
{
"name": "@furystack/logging",
"version": "6.0.0",
"version": "6.0.1",
"description": "Logging API for FuryStack package",

@@ -36,3 +36,3 @@ "type": "module",

"devDependencies": {
"typescript": "^5.4.2",
"typescript": "^5.4.3",
"vitest": "^1.4.0"

@@ -42,6 +42,6 @@ },

"dependencies": {
"@furystack/inject": "^10.0.0",
"@furystack/utils": "^6.0.0"
"@furystack/inject": "^11.0.0",
"@furystack/utils": "^6.0.1"
},
"gitHead": "f83552be5dc0d48b087781b583111a4c88188082"
}

@@ -8,3 +8,3 @@ import { using } from '@furystack/utils'

import { TestLogger } from './test-logger.js'
import { describe, it, expect, vi } from 'vitest'
import { describe, it, expect, vi, afterAll, beforeEach } from 'vitest'

@@ -163,28 +163,99 @@ describe('Loggers', () => {

describe('Scoped Logger', () => {
const scopedConsoleLogger = new ConsoleLogger().withScope('scope')
it('Should print with addEntry', () =>
scopedConsoleLogger.addEntry({ message: 'Example Verbose Message', level: LogLevel.Verbose }))
it('Should print Verbose', () => scopedConsoleLogger.verbose({ message: 'Example Verbose Message' }))
it('Should print Debug', () => scopedConsoleLogger.debug({ message: 'Example Debug Message' }))
it('Should print Information', () => scopedConsoleLogger.information({ message: 'Example Information Message' }))
it('Should print Warning', () => scopedConsoleLogger.warning({ message: 'Example Warning Message' }))
it('Should print Error', () => scopedConsoleLogger.error({ message: 'Example Error Message' }))
it('Should print Fatal', () => scopedConsoleLogger.fatal({ message: 'Example Fatal Message' }))
it('Should print additional data', () =>
scopedConsoleLogger.fatal({ message: 'Example Fatal Message', data: { a: 1 } }))
})
describe('Console Logger', () => {
const scope = 'exampleScope'
describe('ConsoleLogger', () => {
const consoleLogger = new ConsoleLogger()
it('Should print Verbose', () => consoleLogger.verbose({ scope: 'scope', message: 'Example Verbose Message' }))
it('Should print Debug', () => consoleLogger.debug({ scope: 'scope', message: 'Example Debug Message' }))
it('Should print Information', () =>
consoleLogger.information({ scope: 'scope', message: 'Example Information Message' }))
it('Should print Warning', () => consoleLogger.warning({ scope: 'scope', message: 'Example Warning Message' }))
it('Should print Error', () => consoleLogger.error({ scope: 'scope', message: 'Example Error Message' }))
it('Should print Fatal', () => consoleLogger.fatal({ scope: 'scope', message: 'Example Fatal Message' }))
const scopedConsoleLogger = new ConsoleLogger().withScope(scope)
const consoleMock = vi.spyOn(console, 'log').mockImplementation(() => {})
it('Should print additional data', () =>
consoleLogger.fatal({ scope: 'scope', message: 'Example Fatal Message', data: { a: 1 } }))
afterAll(() => {
consoleMock.mockRestore()
})
beforeEach(() => {
consoleMock.mockReset()
})
describe('With scope', () => {
it('Should print with addEntry', async () => {
const message = { message: 'Example Verbose Message', level: LogLevel.Verbose }
await scopedConsoleLogger.addEntry(message)
expect(consoleMock).toHaveBeenCalledWith(...defaultFormat({ ...message, scope }))
})
it('Should print Verbose', async () => {
const message = { message: 'Example Verbose Message' }
await scopedConsoleLogger.verbose(message)
expect(consoleMock).toHaveBeenCalledWith(...defaultFormat({ ...message, level: LogLevel.Verbose, scope }))
})
it('Should print Debug', async () => {
const message = { message: 'Example Debug Message' }
await scopedConsoleLogger.debug(message)
expect(consoleMock).toHaveBeenCalledWith(...defaultFormat({ ...message, level: LogLevel.Debug, scope }))
})
it('Should print Information', async () => {
const message = { message: 'Example Information Message' }
await scopedConsoleLogger.information(message)
expect(consoleMock).toHaveBeenCalledWith(...defaultFormat({ ...message, level: LogLevel.Information, scope }))
})
it('Should print Warning', async () => {
const message = { message: 'Example Warning Message' }
await scopedConsoleLogger.warning(message)
expect(consoleMock).toHaveBeenCalledWith(...defaultFormat({ ...message, level: LogLevel.Warning, scope }))
})
it('Should print Error', async () => {
const message = { message: 'Example Error Message' }
await scopedConsoleLogger.error(message)
expect(consoleMock).toHaveBeenCalledWith(...defaultFormat({ ...message, level: LogLevel.Error, scope }))
})
it('Should print Fatal', async () => {
const message = { message: 'Example Fatal Message' }
await scopedConsoleLogger.fatal(message)
expect(consoleMock).toHaveBeenCalledWith(...defaultFormat({ ...message, level: LogLevel.Fatal, scope }))
})
it('Should print additional data', async () => {
const message = { message: 'Example Fatal Message', data: { a: 1 } }
await scopedConsoleLogger.fatal(message)
expect(consoleMock).toHaveBeenCalledWith(
...defaultFormat({ ...message, level: LogLevel.Fatal, scope, data: { a: 1 } }),
)
})
})
describe('Without scope', () => {
const consoleLogger = new ConsoleLogger()
it('Should print Verbose', async () => {
const message = { message: 'Example Verbose Message', scope }
await consoleLogger.verbose(message)
expect(consoleMock).toHaveBeenCalledWith(...defaultFormat({ ...message, level: LogLevel.Verbose }))
})
it('Should print Debug', async () => {
const message = { message: 'Example Debug Message', scope }
await consoleLogger.debug(message)
expect(consoleMock).toHaveBeenCalledWith(...defaultFormat({ ...message, level: LogLevel.Debug }))
})
it('Should print Information', async () => {
const message = { message: 'Example Information Message', scope }
await consoleLogger.information(message)
})
it('Should print Warning', async () => {
const message = { message: 'Example Warning Message', scope }
await consoleLogger.warning(message)
expect(consoleMock).toHaveBeenCalledWith(...defaultFormat({ ...message, level: LogLevel.Warning }))
})
it('Should print Error', async () => {
const message = { message: 'Example Error Message', scope }
await consoleLogger.error(message)
expect(consoleMock).toHaveBeenCalledWith(...defaultFormat({ ...message, level: LogLevel.Error }))
})
it('Should print Fatal', async () => {
const message = { message: 'Example Fatal Message', scope }
consoleLogger.fatal(message)
expect(consoleMock).toHaveBeenCalledWith(...defaultFormat({ ...message, level: LogLevel.Fatal }))
})
it('Should print additional data', async () => {
const message = { message: 'Example Fatal Message', data: { a: 1 }, scope }
consoleLogger.fatal(message)
expect(consoleMock).toHaveBeenCalledWith(...defaultFormat({ ...message, level: LogLevel.Fatal }))
})
})
})

@@ -191,0 +262,0 @@

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