@cuppachino/logger
v1.1.0
Published
Tiny logging utility for tiny projects. Enjoy colored console output without overthinking it.
Downloads
1
Maintainers
Readme
@cuppachino/logger
Tiny logging utility for tiny projects. Enjoy colored console output without overthinking it.
📦 Installation
pnpm add @cuppachino/logger
pnpm add -D chalk
or
npm install @cuppachino/logger
npm install --save-dev chalk
🔍 Example Usage
import { createLogger } from '@cuppachino/logger'
const logger = createLogger('main' /* Options */)
logger.tag('example', 'blue', 'bold', 'italic').log('hello world')
logger.log('foo').untag()
logger.log('bar')
🛠️ Configuration
colors
: an array of colors/modifiers fromchalk
applied to the logger's prefix (default:'gray'
).tagWrapColors
: an array of colors/modifiers applied to the characters that wrap each tag (default:'dim'
).tagWrapStyle
: the characters used to wrap each tag (default:'square'
).
type LoggerOptions = {
colors: Color[]
tagWrapColors: Color[]
tagWrapStyle: WrapStyle
// "angled" | "square" | "curly" | "parens"
}
💪 Methods
tag
: pushes a tag to the stackuntag
: removes the previous tag from the stack.log
: writes a message to the console, prepended by the logger prefix and any tags.error
: throws an error
✏️ Todo
/*
- transports
- levels-like filtering with tags (ideally avoid upfront logger config)
- maybe more...
*/