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

@alexpekurovsky/logparser

v1.0.3

Published

LogParser is converter from file with single JSON object per line to CSV file.

Downloads

368

Readme

LogParser

LogParser is converter from file with single JSON object per line to CSV file.

This project is done as exam task for IronSource.

Features:

  • Converting single file
  • Converting all files in directory
  • Converting files in directory matching pattern
  • Converting files in directory and subdirectories (recursively) matching pattern
  • Multiple files processing simultaneously

Installation & Usage

$ npm i @alexpekurovsky/logparser [-g]
$ logparser FILENAME  # to process single file
$ logparser DIRNAME   # to process all files in dir
$ logparser DIRNAME -p PATTERN  # to process all files in dir matching mattern
$ logparser DIRNAME -p PATTERN -r  # to process all files in dir and subdirs matching pattern

Examples

$ logparser /var/log/IronSourceApp/IS_main.log
$ logparser /var/log/IronSourceApp
$ logparser /var/log/IronSourceApp -p '*.log'
$ logparser /var/log -p 'IS_*.log' -r

Demo

$ ll
-rw-r--r-- 1 root root 6651236352 Jun 28 01:55 big.log
-rw-r--r-- 1 root root 3815110456 Jun 28 02:18 big.log.csv
-rw-r--r-- 1 root root       2822 Jun 27 23:20 light.log
-rw-r--r-- 1 root root   51962784 Jun 27 22:40 Mundo-json-2013-01-03.log
-rw-r--r-- 1 root root          0 Jun 28 12:01 Mundo-json-2013-01-03.log.csv

$ logparser -h
usage: logparser [-h] [-p PATTERN] [-r] path

Argparse example

Positional arguments:
  path                  Filename or directory to work on

Optional arguments:
  -h, --help            Show this help message and exit.
  -p PATTERN, --pattern PATTERN
                        Filemask to match files. See https://en.wikipedia.
                        org/wiki/Glob_(programming)
  -r, --recursive       Specify this option if you want to check
                        subdirectories for files


$ logparser . -p '*.log'
Processing big.log ...
`-> big.log.csv exists
  `-> File to be created big.log.csv exists. Do you want to [Override/Skip] it:
    `-> Please answer exactly O/S: S
  `-> You skipped processing of big.log
Processing light.log ...
Processing Mundo-json-2013-01-03.log ...
`-> Mundo-json-2013-01-03.log.csv exists
  `-> File to be created Mundo-json-2013-01-03.log.csv exists. Do you want to [Override/Skip] it: O
  `-> Truncating output file Mundo-json-2013-01-03.log.csv
Processing light.log completed.
Processing Mundo-json-2013-01-03.log completed.


$ ll -h
-rw-r--r-- 1 root root 6,2G Jun 28 01:55 big.log
-rw-r--r-- 1 root root 3,6G Jun 28 02:18 big.log.csv
-rw-r--r-- 1 root root 2,8K Jun 27 23:20 light.log
-rw-r--r-- 1 root root 1,8K Jun 28 12:02 light.log.csv
-rw-r--r-- 1 root root  50M Jun 27 22:40 Mundo-json-2013-01-03.log
-rw-r--r-- 1 root root  29M Jun 28 12:02 Mundo-json-2013-01-03.log.csv

License

Feel free to use this code, if needed

More info

Updates to code to work more efficient on big files after Job Offer :)