achorn
TypeScript icon, indicating that this package has built-in type declarations

0.4.0 • Public • Published


Achorn is a colorful, good-looking, fully customizable logging utility for the Browser. It is heavily inspired by @klaussinanis Signale logger for Node.js backend applications.

Core Features

  • Fully customizable
  • No dependencies
  • Webpack Support (for Angular, React, ...)
  • Written and strongly typed in TypeScript
  • Easy to use Timers, e.g. for HTTP requests
  • ... you can even add your own loggers/prefixes!

But does it work in...?

Chrome Firefox IE Opera Safari
Latest Latest 10+ Latest 6.1+

How to Install

Package Manager

# NPM
npm install achorn

# Yarn
yarn add achorn

Don't forget to import Achorn!

import Achorn from "achorn";

CDN

<!-- unpkg -->
<script src="https://unpkg.com/achorn/lib/achorn.js"></script>

<!-- jsdelivr -->
<script src="https://cdn.jsdelivr.net/npm/achorn/lib/achorn.js"></script>

How to Use

The first thing after importing Achorn is creating a new Achorn() instance:

// Without config
const achorn = new Achorn();

// With custom config
const achorn = new Achorn({
    showTimestamp: true,
    globalPrefix: [...]
});

Achorn takes an optional Config object as input. For all config options, see the config interface file.

After the initial setup, you can already use any of Achorns default loggers, which are defined in their dedicated prefixes file. Optionally, you can add your own prefixes/loggers by providing them in the prefixes field in the Config.

Documentation

Timers

The most common use for Timers in Achorn are probably HTTP requests. Here's an example implementation:

// Create timer with custom name (optional)
const timer = achorn.timer("Async");

request("https://google.com")
    .then((res) => {
        timer.success("Request successful! 🎉");
        achorn.info("Result:", res);
    })
    .catch((err) => {
        timer.error("Request failed.");
        achorn.error(err);
    });

Which will then produce this console output:

Readme

Keywords

none

Package Sidebar

Install

npm i achorn

Weekly Downloads

12

Version

0.4.0

License

ISC

Unpacked Size

40.7 kB

Total Files

12

Last publish

Collaborators

  • 4dams