Skip to content

Commit

Permalink
Use named exports for debino
Browse files Browse the repository at this point in the history
  • Loading branch information
satazor committed Dec 23, 2024
1 parent 76ee5c5 commit 92560f6
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 8 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Considering the following example:

```js
// example.js
import debino from '@uphold/debino';
import { debino } from '@uphold/debino';

const child1 = debino('foo');
const child2 = debino('foo:bar');
Expand Down Expand Up @@ -74,7 +74,7 @@ You may also set the log level via the `LOG_LEVEL` environment variable. However
Every call to `debino` creates a child logger based on a root logger. The default root logger is an instance returned by `pino()`, without any options. You may set your own root logger by calling `setRootLogger()`:

```js
import debino, { pino, setRootLogger } from '@uphold/debino';
import { debino, pino, setRootLogger } from '@uphold/debino';

// Call this as soon as possible in your application.
setRootLogger(pino({ redact: ['foo'] }));
Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,6 @@ setRootLogger(pino());
* Exports.
*/

module.exports = debino;
module.exports.debino = debino;
module.exports.pino = pino;
module.exports.setRootLogger = setRootLogger;
5 changes: 2 additions & 3 deletions src/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
*/

import { beforeEach, describe, expect, it, vi } from 'vitest';
import debino, { setRootLogger } from '.';
import { debino, setRootLogger, pino } from '.';

Check failure on line 6 in src/index.test.js

View workflow job for this annotation

GitHub Actions / tests

Member 'pino' of the import declaration should be sorted alphabetically
import debug from 'debug';
import pino, { symbols } from 'pino';

/**
* Tests for `debino()`.
Expand All @@ -29,7 +28,7 @@ describe('debino', () => {

const logger = debino('biz', { serializers });

expect(logger[symbols.serializersSym].foo).toBe(serializers.foo);
expect(logger[pino.symbols.serializersSym].foo).toBe(serializers.foo);
});

it('should return the same logger instance for the same namespace', () => {
Expand Down
3 changes: 1 addition & 2 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@ declare function debino(namespace: string, options?: { prefix?: string, suffix?:

declare function setRootLogger(logger: Logger)

export default debino;
export { setRootLogger, pino }
export { debino, pino, setRootLogger }

0 comments on commit 92560f6

Please sign in to comment.