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

log-gen

v1.0.4

Published

This is a configurable script for generating dummy log file output.

Downloads

8

Readme

Log Gen

This is a configurable script for generating dummy log file output.

Example Usage

The script can be used by the CLI command log-gen. This expects three arguments, an interval, set of amounts and a line format.

For example if you want to generate 5 lines every second (1000ms), where the line contains a random sentence with between 10 and 20 words, you would use this command:

log-gen -i 1000 -a [5] -f "{lorem(10,20)}"

To understand the timing parameters and generator syntax more, read the following two sections.

Outputting to a File

This script simply sends all of its output to stdout. So to capture it as an actual log file you can simply redirect the stdout using > or >>. For example:

log-gen -i 1000 -a [5] -f "{lorem(10,20)}" > ./MyLogFile.log

Timing Configuration

You can specify an interval and a set of amounts of lines to be generated throughout that interval.

For example with an interval of "1000" (ms, so 1 second) and an amounts set of "[2,5]", two lines will be output randomly within the first second and five lines will be output within the next second. This repeats until the process is killed.

Further Examples

  • Eg: 10 lines per second consistently is: -i 1000 -a [10]
  • Eg: 10 and 50 lines per second alternating is: -i 1000 -a [10,50]
  • Eg: 80 lines per second with bursts of 500 lines per second every fifth seconds is: -i 1000 -a [80,80,80,80,500]

Generator Functions

Within the given format argument you can use the generator syntax to produce randomly created content for each line. This format is {name(some,parameters)}, where name is one of the predefined (below) generator functions and the parameters are a comma-separated list of parameters to be passed to the function.

Generator functions are quite simple JavaScript functions, so if you think of one that should be added, feel free to raise an issue or PR on GitHub to suggest it.

Generator Function Names and Parameters

  • {date(format)} - The date at time of the line output, formatted based on the parameter
  • {ip()} - Generates an IP address
  • {choices(some,options)} - Randomly selects one of the parameters passed
  • {range(min,max)} - Generates a number in the range min..max
  • {lorem(min,max)} - Generates a sentence with an amount of words based on min and max
  • {camel(min,max)} - Generates a list of words formatted in PascalCase. Min and max effects the amount of words output.
  • {pascal(min,max)} - Generates a list of words formatted in camelCase. Min and max effects the amount of words output.