A tiny log library that allows you to take events, explanations and solutions and connect them like lego-pieces to create user-friendly logs.
Installation
$ npm install human-logs
Logs
Click on the below buttons to see for yourself amazing your logs will be when using human-logs
Usage
Create your log function once, and use everywhere. One place for all of your logs. TypeScript types inferred like magic.
import { createHumanLogs } from 'human-logs'export const apiLogs = createHumanLogs({events: {project_create_failed: 'Cannot create your project',project_create_success: 'Successfully created your project.'},explanations: {api_unreachable: 'because the API cannot be reached.'},solutions: {check_status_page: {template: 'You can check the status of our services on our status page.',params: {},actions: [{text: 'Go to status page',href: 'https://skosh.dev'}]},project_view: {template: 'View the project.',params: {},actions: [{text: 'View',href: 'https://skosh.dev'}]}}})// You can now use 'apiLogs' to create user-friendly error logs,// by connecting events, explanations and solutions like lego-blocks.const log = apiLogs({events: ['project_create_failed'],explanations: ['api_unreachable'],solutions: ['check_status_page']})console.log(log.message)// => Cannot create your project because the API cannot be reached.// You can check the status of our services on our status page.console.log(log.actions)/* => [{text: 'Go to status page',href: 'https://status.foobar.inc'}]*/console.log(log.toString())// => Cannot create your project because the API cannot be reached.// You can check the status of our services on our status page.// Go to status page (https://status.foobar.inc)