Skip to content

Commit

Permalink
Merge branch 'main' of github.com:Onboardbase/secure-log
Browse files Browse the repository at this point in the history
  • Loading branch information
iamnasirudeen committed Aug 22, 2023
2 parents fb638f3 + 9195ba2 commit add16a5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ yarn add @onboardbase/secure-log # npm i @onboardbase/secure-log

## Usage

Import the SecureLog library at the top level of your project.
Import the SecureLog library at the top level of your project. If you use any env/secret library (e.g. dotenv) in your project, you should import those before importing SecureLog.

```js
import SecureLog from '@onboardbase/secure-log';
Expand All @@ -40,7 +40,7 @@ The SecureLog Library also accepts an object.
```js
export default interface IOptions {
disableOn?: 'development' | 'production'; // You can use this to specify if you want the SecureLog library to be disabled in a specific environment
disableConsoleOn?: 'development' | 'production'; // You can use this to disable console entirely in a specific environment
disableConsoleOn?: 'development' | 'production'; // You can use this to disable the console entirely in a specific environment
}
```

Expand Down
15 changes: 14 additions & 1 deletion test/log.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ const Log = require('../dist');
const mockedLog = jest.fn();

const mockConsoleLog = () => {
mockedLog.mockReset();
console.log = mockedLog;
console.warn = mockedLog;
console.error = mockedLog;
};

let secureLog;
Expand All @@ -13,7 +16,7 @@ const setup = (options = {}) => {
};

describe('Test console.log', () => {
beforeAll(() => {
beforeEach(() => {
setup();
});
it('should have called console.log with hello', () => {
Expand All @@ -24,4 +27,14 @@ describe('Test console.log', () => {
'hello'
);
});

it('should have called console.warn with hello warn', () => {
secureLog.warn('hello warn');
expect(mockedLog).toHaveBeenCalledWith('hello warn');
});

it('should have called console.error with hello error', () => {
secureLog.error('hello error');
expect(mockedLog).toHaveBeenCalledWith('hello error');
});
});

0 comments on commit add16a5

Please sign in to comment.