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

localog

v0.2.7

Published

log helper for developing a cli app

Downloads

17

Readme

Localog

Localog is a developer's utililty to help logging when developing a cli app. It renders logs in another terminal window.

Install

npm i localog

How To

In your package.json:

{
  "scripts": {
    "localog": "localog"
  }
}

Run the server, on a terminal:

npm run localog

Where ever in your app:

import { success } from 'localog'

// success('Hello')

// test this
for(let i = 0; i < 99999; i++)
  success(`${i}: Hello, ${new Date().toISOString()}`)

Methods

Under the hood, localog uses (some) consola functions. It also has some other functionalities:

import {

  // json utilities
  json,
  stringfy,

  // same as consola
  info,
  start,
  warn,
  success,
  error,
  box,

  // utils to set socket file / port
  // to send data to
  setAddress,

  // utils to set separators
  // used in sending data
  setSeparators,

  // utils to close the connection
  // will be done automatically 
  // on exit SIGINT SIGUSR1 SIGUSR2
  close,

} from 'localog'
// or import localog from localog

json

Logging JSON

import { json } from 'localog'

json({ hello: 'world' })
// will print: { hello: 'world' }

stringify

Logging stringified JSON

import { stringify } from 'localog'

stringify({ 
  hello: 'world', 
  message: {
    what: 'is this?',
    oh: 'this is a very complicated json',
    "i will": [
      'need', 'someway',
      'to', 'see', 'all'
    ],
    the: "message",
    "on": new Date()
  } 
})

/* Will output:
{
  "hello": "world",
  "message": {
    "what": "is this?",
    "oh": "this is a very complicated json",
    "i will": [
      "need",
      "someway",
      "to",
      "see",
      "all"
    ],
    "the": "message",
    "on": "2024-06-07T17:03:21.784Z"
  }
}
*/

consola's method

info, start, warn, success, error, and box, are consola's method.

Checkout consola's doc to see how it will look like on the terminal.

setAddress

localog listens and sends data to ./.localog by default. You can change this into any other file, or port number.

{
  "scripts": {
    "localog": "localog --socket='/tmp/my-awesome-socket'"
    // or "localog": "localog --port=5432"
  }
}

In your app:

import { setAddress, success } from 'localog'

// before you log into anything
setAddress('/tmp/my-awesome-socket')
// or setAddress( 5432 )

success('Hello')

setSeparators

localog uses \ufffe and \uffff to separate data from one another. You can set it to any character you want. NOTE: it should be just one character.

{
  "scripts": {
    "localog": "localog --frontSeparator='^' --backSeparator='$'"
  }
}

In your app:

import { setSeparators, success } from 'localog'

// before you log anything
setSeparators('^', '$')

// do your awesome stuff
success('My project is awesome!')

close

The client will open connection to the server. It will keep it open until exit, SIGINT, SIGUSR1, or SIGUSR2 signal is detected.

If you, somehow, need the client localog to shut down connection to it's server, try shutting it down with close.

import { close } from 'localog'

// closing the localog connection
close()

// this will also close the connection
process.exit()

License

MIT