npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

actuar

v1.1.3-0

Published

A logger that provides many options to log data and informations

Downloads

11

Readme

Actuar

A Node.js module that provides colorized console outputs and more

Installation

npm install actuar --save

Usage

Actuar has some methods to configure the global log handling.

setLocalPort(port: number) : void

Set the port, Actuar shall listen on for remote logs. Defaults to 9090.

Actuar.setLocalPort(9876);

setRemotePort(port: number) : void

Set the port, Actuar shall send the logs to. Defaults to 8989.

Actuar.setRemotePort(9876);

setRemoteIp(ip: string) : void

Set the ip, Actuar shall send the logs to. Defaults to "localhost".

Actuar.setRemoteIp("192.154.100.201");

enableDebug() : void

Enables the debug mode. With this enabled, all Actuar.Logger instances will output the Actuar.Logger.debug() - messages. The default value depends on the passed arguments of your app. It is automatically true if you pass "-dbg" or "--debug"

Actuar.enableDebug();

setLogfilesDir(dir: PathLike) : void

Set the directory, where Actuar shall save the logfiles. Defaults to __dirname.

Actuar.setLogfilesDir("./myLogs");

getLogfilesDir() : PathLike

returns the absolute path to the logfiles directory.

Actuar.getLogfilesDir());

Actuar.Logger

Javascript

let Actuar = require('actuar');
let Logger = new Actuar.Logger('app');
Logger.error("Unexpected Data", 52, __filename);
# Output should be
E! [ 08:20:23 ] - APP : Unexpected Data (/path/to/your/application.js:52)
# (in red)

TypeScript

import * as Actuar from 'actuar';
let Logger = new Actuar.Logger('Server');
Logger.warn("Unathorized access!");
# Output should be
W! [ 08:09:55 ] - SERVER : Unathorized access!
# (in yellow)

log(message: string) : void

Standard output in orange.

warn(message: string, line?: number, file?: string): void

A warning message in yellow. Line number and a file can be specifed to give a link to the code, where the method was called.

error(message: string, line?: number, file?: string): void

An error message in red. Line number and a file can be specifed to give a link to the code, where the error occured.

debug(message: string, line?: number, file?: string): void

A debug message in yellow. Line number and a file can be specifed to give a link to the code, where the method was called. It will be printed if the debug mode is true. (Actuar.enableDebug());

mute() / unmute() - chainable

Enables / disables muting. Defaults to false. Muting will prevent the console output of the logger.

writable() / unwritable() - chainable

Enables / disables writing. Defaults to true. Unwritable will prevent the logger from writing the data into the logfile.

remote() / unremote() - chainable

Enables / disables remote. Defaults to false. Remote will cause the logger to send every log to a remote instance of Actuar.

Remote Logging

If there are multiple devices that have to log data and information, the logger can be setup as remote logger. The follwoing example will create a logger, that send it logs to 'localhost:9090'. The Actuar instance on localhost parses incoming messages, saves the messages into a local logfile and print it out into the console.

Example

import * as Actuar from "../src/Actuar";

Actuar.setLogfilesDir("./logs");
Actuar.setRemotePort(9090);
Actuar.setRemoteIp('localhost');
Actuar.Transceiver.logRemotes();

const Logger = new Actuar.Logger("sandbox").remote();
Logger.log("Hello World!");