@cuppachino/logger
TypeScript icon, indicating that this package has built-in type declarations

1.1.0 • Public • Published

@cuppachino/logger

Tiny logging utility for tiny projects. Enjoy colored console output without overthinking it.

📦 Installation

@cuppachino/logger

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')

Example log output

🛠️ Configuration

  • colors: an array of colors/modifiers from chalk 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 stack
  • untag: 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... 
*/

Package Sidebar

Install

npm i @cuppachino/logger

Weekly Downloads

1

Version

1.1.0

License

GPL-3.0

Unpacked Size

74 kB

Total Files

6

Last publish

Collaborators

  • cuppachino