Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

achorn

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

achorn

🌰 A colourful, good looking, fully customisable logger for the browser

  • 0.2.5
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source


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...?

ChromeFirefoxIEOperaSafari
Latest ✔Latest ✔10+ ✔Latest ✔6.1+ ✔

How to Install

NPM

npm install achorn

Yarn

yarn add 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.

Timers

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

// Create new Timer called "Async"
const timer = achorn.timer("Async");

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

Local Development

After cloning the repository, all you have to do is run npm run watch to start Webpack in watch mode, which will listen for file changes and rebuild Achorn accordingly.

Then, simply open the index.html of this project in the browser!

FAQs

Package last updated on 30 Jun 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc