bruno-sartori / weeb-logger

A visual logging tool with your favorite waifu
MIT License
18 stars 3 forks source link
animes animme chromecast debugger debugging javascript log logger manga otaku shell smarttv terminal tizen typescript waifu weboos weeb

MIT License NPM Version Build Passing

Weeb Logger

Weeb Logger is a JS Canvas component for logging on devices that are problematic to use debugging tools (specially if you are using some external framework for developing those ahead) like Samsung Tizen, LG webOS or Chromecast. Plus you can customize it with your favorite waifu! :3

Installation

Use your favorite package manager, mine is:

yarn add @bsartori/weeb-logger

Usage

import logger from '@bsartori/logger';

logger.configure({
  enabled: true,
  visual: true,
  enableStackTrace: true,
  containerStyle: {
    position: 'bottom-left',
    width: 800,
    height: 800,
    opacity: 1,
    lineHeight: 20,
  },
  waifu: {
    name: 'alya',
    useTheme: true,
    showWaifu: true,
  },
});

logger.info('SOME LABEL', 'A string or object here!');
logger.warn('WARN', 'This is an warning');
logger.error('Api Error', 'This is an error');
logger.success('JSON', { lorem: 'ipsum', dolor: {
  sit: 'amet'
}});
logger.highlight('IMPORTANT', 'This is an highlight info');
try {
  throw new Error('I can also log Error objects!');
} catch (error: any) {
  logger.error('ERROR OBJECT', error);
}

On DevTools this will result in:

Log in DevTools

And in your application:

Log in DevTools

You can also resize the container:

Log in DevTools

Log Message Structure

// message ---------------------------------------+
// label -------------------------+               |
// time diff from last log ---+   |               |
// datetime ---+              |   |               |
//             v              v   v               v
    [31/08/24 10:41:21:457] 10ms INFO - Lorem ipsum dolor sit amet

Available Waifus

akeno alya
tohka aqua
ayano darkness
koneko masha
megumin yuki
zerotwo

API

Configuration Object

Methods

logger.info(label: string, message: string | object) => void

Shows log with a blue label.

logger.success(label: string, message: string | object) => void

Shows log with a green label.

logger.warn(label: string, message: string | object) => void

Shows log with a yellow label. Shows stacktrace on DevTools.

logger.error(label: string, message: string | object) => void

Shows log with a red label. Shows stacktrace on DevTools and if the message is an instance of Error object it will also show stack trace on the visual container.

logger.highlight(label: string, message: string | object) => void

Shows log with a purple label.

logger.clear() => void

Clears the log container and DevTools console screen.

Testing

To test the package, simply run:

yarn test

Please make sure all tests pass before submiting a PR

Log in DevTools

Roadmap

Would love Pull requests that build towards these objectives and even ideas for new objectives :3

Technologies used in this project

Name Description
Node.js Node.js is a Javascript runtime build on Chrome`s V8 JavaScript
Jest Jest is a JavaScript framework for testing
Typescript Typescript extends JavaScript by adding types to the language
Chalk Chalk is a Node.js dependency for terminal string
stacktrace.js stacktrace.js is a Node.js module for formatting JavaScript stack traces in all browsers
Canvas Canvas provides a means for drawing graphics via JavaScript and the HTML element

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT