Skip to content

Commit

Permalink
fix(log.js): Move from MPL log lib to MIT (#405)
Browse files Browse the repository at this point in the history
  • Loading branch information
igoroctaviano authored Oct 15, 2024
1 parent 7b44953 commit 96a068e
Show file tree
Hide file tree
Showing 10 changed files with 5,151 additions and 17,647 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,5 @@
node_modules
.idea
yarn-error.log
yarn.lock
.DS_Store
build
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,3 +163,7 @@ The developers gratefully acknowledge their research support:
- The [Neuroimage Analysis Center](http://nac.spl.harvard.edu)
- The [National Center for Image Guided Therapy](http://ncigt.org)
- The [NCI Imaging Data Commons](https://imagingdatacommons.github.io/) NCI Imaging Data Commons: contract number 19X037Q from Leidos Biomedical Research under Task Order HHSN26100071 from NCI

## Logging

This library uses [loglevel](https://github.com/pimterry/loglevel) for logging. By default, the log level is set to "warn". You can change the log level by setting the `LOG_LEVEL` environment variable or by using the `setLevel` method in your code.
21 changes: 21 additions & 0 deletions jest.setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Mock loglevel
const createMockLogger = () => ({
debug: jest.fn(),
info: jest.fn(),
warn: jest.fn(),
error: jest.fn(),
setLevel: jest.fn()
});

const mockLog = createMockLogger();

mockLog.create = jest.fn(name => {
const namedLogger = createMockLogger();
namedLogger.name = name;
return namedLogger;
});

jest.mock("loglevel", () => mockLog);

// Optionally, if you want to make the mock available globally for easier assertions
global.mockLog = mockLog;
Loading

0 comments on commit 96a068e

Please sign in to comment.