How to use the @financial-times/n-logger.error function in @financial-times/n-logger

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]);
		});

@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

45 / 100
Full package analysis

Popular @financial-times/n-logger functions

Similar packages