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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@outlawdesigns/access-log-parser

v1.0.0

Published

**A lightweight Node.js module for parsing Apache-style HTTP access logs**

Readme

Access Log Parser

A lightweight Node.js module for parsing Apache-style HTTP access logs

This module extracts key fields—IP address, request method, URL/query, timestamps, referrer, response code, response size, and user-agent details—from standard Apache access log lines. It is designed to be small, dependency-light, and easy to integrate into log-processing pipelines.


✨ Features

  • Extracts:

    • IP address (including handling of IPv6 ::1127.0.0.1)
    • Timestamp → JavaScript Date object
    • HTTP method
    • Query/path
    • Referrer
    • Response code
    • Response size
    • Full parsed user-agent (via parse-user-agent)
  • Provides a parseLine() helper that extracts all values at once

  • No external Apache configuration required—parses raw log lines


📦 Installation

npm install @outlawdesigns/access-log-parser

🚀 Usage

const fs = require('fs');
const AccessLogParser = require('@outlawdesigns/access-log-parser');
const logPath = '/var/log/apache2/access.log';

let data = fs.readFileSync(logPath, 'utf8').split("\n");

data.forEach((line) => {
  console.log(AccessLogParser.parseLine(line));
});

Sample output:

{
  "ip_address": "127.0.0.1",
  "responseCode": "200",
  "requestDate": "2024-01-01T12:34:56.000Z",
  "requestMethod": "GET",
  "query": "/index.html",
  "referrer": "https://example.com",
  "responseSize": "5321",
  "ua": "Mozilla/5.0...",
  "browser": { ... },
  "engine": { ... },
  "os": { ... },
  "device": { ... }
}

🧩 API Reference

parseIp(logStr)

Returns the client IP address. IPv6 loopback (::1) is mapped to 127.0.0.1.

parseDate(logStr)

Returns a JavaScript Date based on the Apache timestamp.

parseTimeZone(logStr)

Returns the timezone offset (e.g. -0600).

parseMethod(logStr)

Extracts the HTTP verb (GET, POST, etc.).

parseQuery(logStr)

Extracts the request target (path/query).

parseReferrer(logStr)

Returns the request referrer, if present.

parseResponseCode(logStr)

Extracts the numeric HTTP status code.

parseResponseSize(logStr)

Response payload size in bytes.

parseUserAgent(logStr)

Parses the User-Agent header using parse-user-agent.

parseLine(logStr)

Returns a full object with all possible parsed fields.


🛠 Example: Processing a Log Stream

const readline = require('readline');
const fs = require('fs');
const parser = require('@outlawdesigns/access-log-parser');

const rl = readline.createInterface({
  input: fs.createReadStream('/var/log/apache2/access.log'),
  crlfDelay: Infinity
});

rl.on('line', line => {
  const record = parser.parseLine(line);
  if (record) console.log(record);
});

🧪 Notes

  • The parser assumes your access logs follow an Apache combined-style pattern.
  • Malformed or incomplete lines return false.
  • All regexes are intentionally optimized for speed and low overhead.

📄 License

MIT