Skip to content

Commit 96a068e

Browse files
fix(log.js): Move from MPL log lib to MIT (#405)
1 parent 7b44953 commit 96a068e

10 files changed

+5151
-17647
lines changed

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,5 @@
55
node_modules
66
.idea
77
yarn-error.log
8-
yarn.lock
98
.DS_Store
109
build

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -163,3 +163,7 @@ The developers gratefully acknowledge their research support:
163163
- The [Neuroimage Analysis Center](http://nac.spl.harvard.edu)
164164
- The [National Center for Image Guided Therapy](http://ncigt.org)
165165
- 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
166+
167+
## Logging
168+
169+
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.

jest.setup.js

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Mock loglevel
2+
const createMockLogger = () => ({
3+
debug: jest.fn(),
4+
info: jest.fn(),
5+
warn: jest.fn(),
6+
error: jest.fn(),
7+
setLevel: jest.fn()
8+
});
9+
10+
const mockLog = createMockLogger();
11+
12+
mockLog.create = jest.fn(name => {
13+
const namedLogger = createMockLogger();
14+
namedLogger.name = name;
15+
return namedLogger;
16+
});
17+
18+
jest.mock("loglevel", () => mockLog);
19+
20+
// Optionally, if you want to make the mock available globally for easier assertions
21+
global.mockLog = mockLog;

0 commit comments

Comments
 (0)