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

joblog

v1.0.0

Published

Standardized logging for batch jobs and others.

Downloads

3

Readme

Joblog

The Joblog library provides a simple logging system. It’s ideal for batch jobs but can also be used for longer running systems.

Features

  • Log format compatible with Google Logging Library.
  • Log files are automatically written to a directory tree arranged by date with unique names.
  • Available for several programming languages.
  • Status lines logged automatically at start and exit.

Example

This example demonstrates many of the features:

$ node example.js
I0127 160235.292 [20M] logging to logs/2016/201601/20160127/20160127_160235_example_6232_pocitac.log
I0127 160235.304 [21M] start example: node v4.2.6 linux, hostname pocitac, user james
I0127 160235.306 [21M] invoked as: /usr/bin/nodejs /home/james/Projects/joblog/example.js --run

I0127 160235.307 [21M] running example
I0127 160235.312 [22M] processed 100000/1324025 (7.6%), sum 4957425
I0127 160235.316 [22M] processed 200000/1324025 (15.1%), sum 9910422
I0127 160235.319 [22M] processed 300000/1324025 (22.7%), sum 14858261
I0127 160235.321 [22M] processed 400000/1324025 (30.2%), sum 19814380
I0127 160235.324 [22M] processed 500000/1324025 (37.8%), sum 24758867
I0127 160235.326 [22M] processed 600000/1324025 (45.3%), sum 29711562
I0127 160235.328 [22M] processed 700000/1324025 (52.9%), sum 34665519
I0127 160235.330 [22M] processed 800000/1324025 (60.4%), sum 39619914
I0127 160235.333 [22M] processed 900000/1324025 (68.0%), sum 44573943
I0127 160235.335 [22M] processed 1000000/1324025 (75.5%), sum 49515369
I0127 160235.337 [22M] processed 1100000/1324025 (83.1%), sum 54484107
I0127 160235.339 [22M] processed 1200000/1324025 (90.6%), sum 59447012
I0127 160235.341 [22M] processed 1300000/1324025 (98.2%), sum 64397686
I0127 160235.342 [22M] processed 1324025/1324025 (100.0%), sum 65590458
W0127 160235.342 [22M] final sum 65590458

I0127 160235.346 [22M] exit example: pid 6232, real 0.059s, user 0.00s, system 0.00s, read 31K, written 2K, peak rss 22M
  • The log is written to standard error as well as to the log file.
  • All times are in UTC.
  • The format is "<month/day> [RSS] message".
  • The log file name contains the date, time, program name, pid, and hostname. The resulting tree is safe to rsync to a central store where it will not overwrite logs from other jobs or machines.
  • The first lines show the environment and command line.
  • The last line shows run time, IO stats, and memory usage.

Usage

Javascript (Node)

npm install jamesbursa/joblog
var joblog = require("joblog");
joblog.info("processed %i/%i", i + 1, total);
joblog.warn("final sum %i", sum);

Python

import joblog
import logging

logging.info("%i/%i (%.1f%%) processed", i + 1, total, 100.0 * (i + 1) / total)
logging.warn("all done")

Compatible with Python 2 and 3.