How to use @financial-times/n-logger - 4 common examples

To help you get started, we’ve selected a few @financial-times/n-logger examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Financial-Times / n-auto-logger / src / __tests__ / failure-logger.js View on Github external
it('ExtendedError', async () => {
			const e = new ExtendedError({
				user: {
					message: 'some message',
					email: 'some email address',
				},
			});
			await failureLogger()(e);
			expect(logger.error.mock.calls).toHaveLength(1);
			const loggedError = logger.error.mock.calls[0][0];
			expect(loggedError.user).toBeUndefined();
		});
github Financial-Times / n-auto-logger / src / __tests__ / failure-logger.js View on Github external
it('fetch response error with status', async () => {
			const headers = new Headers();
			headers.append('content-type', 'text/plain; charset=utf-8');
			const errorResponse500 = new Response('500 Internal Server Error', {
				status: 500,
				headers,
			});
			await failureLogger()(errorResponse500);
			expect(logger.error.mock.calls).toHaveLength(1);
			assertErrorLog(logger.error.mock.calls[0][0]);

			const errorResponse404 = new Response('404 Not Found', {
				status: 404,
				headers,
			});
			await failureLogger()(errorResponse404);
			expect(logger.error.mock.calls).toHaveLength(1);
			expect(logger.warn.mock.calls).toHaveLength(1);
			assertErrorLog(logger.warn.mock.calls[0][0]);
		});
github Financial-Times / n-auto-logger / src / __tests__ / failure-logger.js View on Github external
it('null or undefined input', async () => {
			const context = {
				operation: 'someOperation',
				action: 'someAction',
			};
			await failureLogger(context)();
			expect(logger.warn.mock.calls).toHaveLength(1);
			expect(logger.warn.mock.calls[0][0]).toMatchSnapshot();
		});
github Financial-Times / n-auto-logger / src / __tests__ / failure-logger.js View on Github external
const extendedSystemError = nError({
				status: 500,
				message: 'some error message',
			});
			await failureLogger()(extendedSystemError);
			expect(logger.error.mock.calls).toHaveLength(1);
			assertErrorLog(logger.error.mock.calls[0][0]);

			const extendedSystemError404 = nError({
				status: 404,
				message: 'some error message',
			});
			await failureLogger()(extendedSystemError404);
			expect(logger.error.mock.calls).toHaveLength(1);
			expect(logger.warn.mock.calls).toHaveLength(1);
			assertErrorLog(logger.warn.mock.calls[0][0]);
		});

@financial-times/n-logger

This package provides a Winston wrapper which sends server-side logs to Splunk's HTTP Event Collector (HEC).

MIT
Latest version published 2 years ago

Package Health Score

48 / 100
Full package analysis

Popular @financial-times/n-logger functions

Similar packages