The internal about common isomorphic logger with namespace.
npm install @rcp/util.createlogger
# or use yarn
yarn add @rcp/util.createlogger
import createLogger from '@rcp/util.createlogger'
const logger = createLogger('@rcp/hoc.i18n')
logger.info('%s abc', 'ok') // alias `log`
logger.success({ a: '222' }, 'ok')
logger.warn({})
logger.debug()
logger.error()
logger.invariant(typeof document !== 'undefined', 'the library should be used in browser environment.')
The namespace of logger.
-
prefix: (default:
'('
) -
suffix: (default:
')'
) -
typeMap: eg
{ Log: "I'm a Log", Success: "Wow!", Warning: "Warn!", Error: "Error happened", }
The formatted string are composed by {type}{prefix}{namespace}{suffix}: {message}
.
e.g. Success(foo): Done!
- Type:
function
- Type:
function
- Type:
function
- Type:
function
- Type:
function
It will throw Error with message
when check
is false
- Type:
(check: boolean, message?: string) => void
This library is written and maintained by imcuttle, mailto:moyuyc95@gmail.com.
MIT