1.1.8 • Published 3 years ago
sweet-console v1.1.8
sweet console
this simple package makes it easy to style your console output
install
npm i sweet-console
browser use
const msg = 'sweet console (pck)'
sw.log(`log :${msg}`)
sw.info(`info :${msg}`)
sw.warn(`warn :${msg}`)
sw.error(`error :${msg}`)
//global style
const msg = 'Sweet Console (pck)'
sw.style({
'log':{color:'#000',background:'#222',margin:5,padding:8},
'info':{color:'#000',background:'#222',margin:5,padding:8},
'warn':{color:'#ffffff',background:'#ff0000',margin:5,padding:8},
'error':{
'color':'#ffffff','background':'#d83232','padding':8,
'border-color':'#005cc5','border-width':5
}
})
sw.log(`log :${msg}`)
sw.info(`info :${msg}`)
sw.warn(`warn :${msg}`)
sw.error(`error :${msg}`)
//params style
const msg = 'Sweet Console (pck)'
sw.log(`log :${msg}`,{color:'#000',background:'#222',margin:5,padding:8})
//or string style,full style support
sw.warn(
`warn :${msg}`,
'color:#586069;background:#d73a49;padding:8px;margin-left:5px'
)
node.js use (chalk dependencies)
var sw = require('sweet-console')
sw.log(`log ${msg}`,{color:'#ffffff'}) //params
sw.error(`error ${msg}`) //default styles
sw.warn(`warn ${msg}`,{color:'#ffffff'}) //params
sw.info(`info ${msg}`,{color:'#0000',background:'#FFEC8B'}) //params
//note : params style only object , string not supported
//global style
sw.style({
'log':{ margin:8},
'error':{padding:3},
'warn':{color:'#0000'},
'info':{background:'#ffffff'}
})