@@ -2,8 +2,9 @@ import { emitWarning } from 'process'
22
33import filterObj from 'filter-obj'
44import { multipleValidOptions } from 'jest-validate'
5+ import mapObj from 'map-obj'
56
6- import { result , mapValues } from './utils.js'
7+ import { result } from './utils.js'
78
89// Retrieve error's log level
910export const getLevel = function ( { opts, name, error } ) {
@@ -36,7 +37,10 @@ export const applyDefaultLevels = function ({
3637 return { ...DEFAULT_LEVEL , ...levelA }
3738 }
3839
39- const defaultLevels = mapValues ( DEFAULT_LEVEL , ( ) => defaultLevel )
40+ const defaultLevels = mapObj ( DEFAULT_LEVEL , ( eventName ) => [
41+ eventName ,
42+ defaultLevel ,
43+ ] )
4044 return { ...defaultLevels , ...levelA }
4145}
4246
@@ -46,12 +50,12 @@ const isDefined = function (key, value) {
4650
4751// Use during options validation
4852export const getExampleLevels = function ( ) {
49- return mapValues ( DEFAULT_LEVEL , getExampleLevel )
53+ return mapObj ( DEFAULT_LEVEL , getExampleLevel )
5054}
5155
52- const getExampleLevel = function ( level ) {
56+ const getExampleLevel = function ( eventName , level ) {
5357 // eslint-disable-next-line no-empty-function
54- return multipleValidOptions ( level , ( ) => { } )
58+ return [ eventName , multipleValidOptions ( level , ( ) => { } ) ]
5559}
5660
5761export const validateLevels = function ( { level } ) {
@@ -77,7 +81,7 @@ const isValidLevel = function ({ level }) {
7781const LEVELS_ARR = [ 'debug' , 'info' , 'warn' , 'error' , 'silent' , 'default' ]
7882const LEVELS = new Set ( LEVELS_ARR )
7983
80- export const DEFAULT_LEVEL = {
84+ const DEFAULT_LEVEL = {
8185 default : 'error' ,
8286 uncaughtException : 'error' ,
8387 warning : 'warn' ,
0 commit comments