log-beautify
Show log messages on your terminal with style :-) . Use debugging levels to enable or disable log messages.
Installation
npm install log-beautify
Usage
const log = ; log;//change the level to use tracelog;log;//success aliaslog;log;log;log;//warning aliaslog;
Use case :-)
API
Log methods
log.success()
(for text color)log.success_()
(for background color)log.ok()
(log.success() alias)log.ok_()
(log.success_() alias)log.debug()
log.debug_()
log.info()
log.info_()
log.warning()
log.warning_()
log.warn()
(log.warning() alias)log.warn_()
(log.warning_() alias)log.error()
log.error_()
log.show()
(default console.log())
You can create your own log methods, for example:
log;log; //Now you can use itlog;
Log levels
Global level is: 1
Default level for new log methods: 1
Default levels:
silent: -1//hide all logs trace: 0 success: 1 debug: 2 info: 3 warning: 4 error: 5
Config
log.useSymbols = true
(Enable or disable symbols)log.useLabels = true
(Enable or disable labels)log.setColors({})
(Add or change colors)log.setSymbols({})
(Add or change symbols)log.setLabels({})
(Add or change labels)log.setTextColors({})
(Change text colors for bg logs)log.setLevel(1)
(Change global level, default = 1)log.setLevel(1, 'namespace')
(log.setNamespaceLevel() alias)log.setNamespaceLevel(1, 'namespace')
(Create level with namespace and use it in current file, The global level will be ignored)log.namespace('namespace')
(log.useNamespace() alias)log.useNamespace('namespace')
(Use the level of a namespace in the current file, The global level will be ignored. You can use namespaces created in other files)log.setLocalLevel(1)
(Create a level to use only in the current file, The global level will be ignored)log.setLevels({})
(Add or change levels)
Colors
You can use the following color formats. (Use strings)
keyword
Example:"red"
(black,white,red,green,yellow,magenta,cyan,gray)hex
Example:"#FFF000"
rgb
Example:"rgb(255, 255, 255)"
hsl
Example:"hsl(0, 100%, 50%)"
hsv
Example:"hsv(330, 93%, 98%)"
hwb
Example:"hwb(0, 100%, 0%)"
Usage examples
/**|--------------------------------------------------| Disable symbols|--------------------------------------------------*/loguseSymbols = false; /**|--------------------------------------------------| Disable labels|--------------------------------------------------*/loguseLabels = false; /**|--------------------------------------------------| Change colors|--------------------------------------------------*/log; /**|--------------------------------------------------| Add or change new log methods|--------------------------------------------------*///When you add a color, the method will automatically be created.log;//Now you can use log.danger() and log.danger_() and log.saved() /**|--------------------------------------------------| Add or change symbols|--------------------------------------------------*/log; /**|--------------------------------------------------| Add or change labels|--------------------------------------------------*/log; /**|--------------------------------------------------| Add or change text colors for bg logs|--------------------------------------------------*/log; /**|--------------------------------------------------| Add or change levels|--------------------------------------------------*/log; /**|--------------------------------------------------| Change global level. 2 = "debug"|--------------------------------------------------*/log;//log.setLevel('debug'); /**|--------------------------------------------------| Add level "info = 3" to use only in the current file, The global level will be ignored|--------------------------------------------------*/log; /**|--------------------------------------------------| Create level with namespace and use it in current file, The global level will be ignored|--------------------------------------------------*/log; /**|--------------------------------------------------| Use namespace created previously. You can use namespaces created in other files.|--------------------------------------------------*/log;//log.namespace('show-only-errors');
Collaborators
Thanks
License
MIT