Socket
Socket
Sign inDemoInstall

log-gen

Package Overview
Dependencies
54
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    log-gen

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


Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Install size
726 kB
Created
Weekly downloads
 

Readme

Source

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.

FAQs

Last updated on 31 Oct 2016

Did you know?

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc