Beautiful & Customizable logger ❤️
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.editorconfig Update .editorconfig Jan 27, 2018
.gitignore
.npmrc Create .npmrc Jan 27, 2018
.prettierrc Code format Oct 24, 2018
.travis.yml 🔧 Oct 25, 2018
LICENSE Jesus... Jan 16, 2018
README.md fix 🦄 Oct 25, 2018
example.js fix code style Oct 26, 2018
example.svg fix Jul 17, 2018
index.js
package.json update version number Oct 25, 2018

README.md

xa

Beautiful & Customizable log messages in your terminal ❤️

Build Status XO Code Style Unicorn

Screenshot

Installation

npm install --save xa

Usage

Default logger is usign only stdoutHandler which accepts these types of logging

  • info: (label, message)

  • loading: (label, message)

  • warn: (label, message)

  • experimental: (label, message)

  • on: (label, message)

  • off: (label, message)

  • error: (message)

Example

See example.js file.

const xa = require("xa");

xa.info("SUCCESS", "Finished converting file!");

xa.warn(
	'WARN',
	`This module is deprecated! Read more: ${xa.link('http://example.com')}`
);

Customize

xa uses chalk for colorful output, so you can customize technically every color 🦄

Handlers

Logger({
	handlers: [
		stdoutHandler({
			info: "magenta",
			error: "blue"
		})
	]
});

Handlers are functions that are called when you are logging something. You are able to use predefined one or you can create it by your own like this:

function mineHandler(options = defaultOptions) {
	return (type, label, message) => {
		switch (type) {
			case "error":
				DB.insert({
					into: "errors",
					date: new Date(),
					message,
					label
				});
				break;
			default:
				DB.insert({
					into: "logs",
					date: new Date(),
					message,
					label
				});
				break;
		}
	};
}

stdoutHandler customization

stdoutHandler accepts object with names of acceptable log methods and their display color as values.

const stdoutHandlerOptions = {
	error: "red",
	experimental: "magenta",
	info: "green",
	loading: "blue",
	off: "gray",
	on: "white",
	warn: "yellow"
};

Thanks:

License

MIT © Antoni Kepinski