Catalog npm
Back to packageRELEASE DETAILS

1.0.3

npm

5w-logger

5w logger library

Published27 Aug 2026
Direct dependencies14
Transitive dependenciesNot calculated

README

Current package documentation

5w Logger

How to use


...

import * as logger from "5w-logger";

const requestId = req.requestId
const event = getMadeUpEvent()
const context = getMadeUpContext()

const logger = new logger.LogSpan(requestId)

logger.info(`lambda.handler.start`, `Calling Lambda callback.`, `request`, 'SYSTEM', { event, context })
logger.info(`lambda.handler`, `Logs have been parsed and transformed. Ready to push into separate destinations.`, `debug`)
logger.info(`lambda.handler.firehose`, `Pushing logs to Firehose.`, `debug`)
logger.error(`lambda.handler.firehose.catch`, `Could not push logs to Firehose.`, `debug`, system, { error })

// Uh at this point I'm pretty sure you know how to use this... Try it out.

...

Target

Use logging to ease debugging problems, improve security auditing, improve identifying problems in security, make logging compliant to ISO 27002 standard.

Snippet from the Finnish Standards Association SFS's ISO 27002 description:

"Event logs recording user activities, exceptions, faults and information security events should be produced, kept and regularly reviewed."

Logs should answer to 5W or When (was the activity performed), Whence (the activity originated), Who (or what performed the activity), What (activity was performed), Where (in the system the activity got handled). Each activity should have its own unique identifier to ease the audit trail.

5w Logger is inspired by checkout-logger TypeScript library (https://github.com/CheckoutFinland/checkout-logger)

Structure

{
    "timestamp": "2017-11-08T07:27:04+00:00",
    "level": "info" | "debug" | "error" | "warning",
    "rid": "1232131",
    "type": "person.viewed",
    "message": "the actual content that was logged for magic crap",
    "group": "audit" | "request" | "response" | "debug" | "session" | "security" | "technical",
    "user": "SYSTEM",
    "meta": {
        "some": "info"
    }
}

Timestamp

Well formatted timestamp. Generated automatically.

Levels

Supported log leves are info, debug, error and warning.

  • Error: Use when the system has run into a fatal exception that we cannot automatically recover from and require attention from developers.
  • Warning: Use for 90% of catch cases and error handling.
  • Info: Normal information type logging.
  • Debug: General developer friendly spam that is wanted in the logs for common "what the hell just happened" type of solving.

Request ID

Request ID from headers or request when it's available. Otherwise leave it empty and the Logger will generate a valid UUID-V4 for it.

Message

Freeform message that should be unique and link you instantly to the case at hand. Requires the use of higher brain functionality to get in place properly. Think of it like well formatted Git commit messages.

Type

Links the case into a specific place in the system. For example lambda.image_processing, chat_api, and so on. Again, higher brain functionality should be used when naming this. Does not need to be as unique as RID or Message. It can be a function name from a specific piece of the software or a component name or something similar.

Group

  • There supported log groups are
    • "audit"
    • "request"
    • "response"
    • "debug"
    • "session"
    • "security"
    • "technical"

Audit

Used for specific auditing trail purposes. Everything that might require somewhat reasonable auditing trail.

Request

Can contain any linking information from the client sent Request. Aims to make the request debugging and observing easier. Make sure to strip out any sensitive inputs or mask them properly.

Response

Can contain any linking information from the information sent as Response to the client sent Request. Aims to make the response debugging and observing easier. Make sure to strip out any sensitive inputs or mask them properly.

User

This can be a named user or "SYSTEM" to indicate the log row was written by the system and not directly caused by a user doing something.

Meta

Meta object. Can be any JSON document that is considered helpful in debugging and needed to maintain sensible logs. Make sure to strip out any sensitive inputs or mask them properly.

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Declared dependencies 14

Native requirements
14 direct targetsNot calculated transitive count
Package / targetRequirementRelationship
uuid
Environment
{
  "local_name": "uuid",
  "alias": false,
  "peer_metadata": null
}
14.0.0runtime
chai
Environment
{
  "local_name": "chai",
  "alias": false,
  "peer_metadata": null
}
6.2.2development
mocha
Environment
{
  "local_name": "mocha",
  "alias": false,
  "peer_metadata": null
}
11.8.0development
globals
Environment
{
  "local_name": "globals",
  "alias": false,
  "peer_metadata": null
}
^17.11.0development
ts-node
Environment
{
  "local_name": "ts-node",
  "alias": false,
  "peer_metadata": null
}
10.9.2development
@eslint/js
Environment
{
  "local_name": "@eslint/js",
  "alias": false,
  "peer_metadata": null
}
^10.0.1development
typescript
Environment
{
  "local_name": "typescript",
  "alias": false,
  "peer_metadata": null
}
6.0.3development
@types/chai
Environment
{
  "local_name": "@types/chai",
  "alias": false,
  "peer_metadata": null
}
5.2.3development
@types/node
Environment
{
  "local_name": "@types/node",
  "alias": false,
  "peer_metadata": null
}
26.4.0development
@types/mocha
Environment
{
  "local_name": "@types/mocha",
  "alias": false,
  "peer_metadata": null
}
10.0.10development
typescript-eslint
Environment
{
  "local_name": "typescript-eslint",
  "alias": false,
  "peer_metadata": null
}
^8.68.0development
eslint-plugin-functional
Environment
{
  "local_name": "eslint-plugin-functional",
  "alias": false,
  "peer_metadata": null
}
^10.0.0development
@typescript-eslint/parser
Environment
{
  "local_name": "@typescript-eslint/parser",
  "alias": false,
  "peer_metadata": null
}
^8.68.0development
@typescript-eslint/eslint-plugin
Environment
{
  "local_name": "@typescript-eslint/eslint-plugin",
  "alias": false,
  "peer_metadata": null
}
^8.68.0development

Distribution files

1 collected
Distribution 1

Source distribution

Source file
Checksums from source
{
  "shasum": "5173185f7ba39bef9fab7125480290e77e4c43bc",
  "tarball": "https://registry.npmjs.org/5w-logger/-/5w-logger-1.0.3.tgz",
  "fileCount": 21,
  "integrity": "sha512-ifcpXERMk6JlhrtF0mgNFAlv2GaPu5H4PzWSXkleQ39wXOd3eNE42aQ/jBcKyxyPcvvsT3oPIkd0HFf4cZMw+A==",
  "signatures": [
    {
      "sig": "MEQCIEYDPLMYHaKKBeng5uM+M2JQ4W3sKUoyAshP323SqaVYAiA6+O4B72VjFvdHQK56Gm0lNS/W2FmcqA2PU27UihoL9w==",
      "keyid": "SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"
    }
  ],
  "unpackedSize": 56282
}

Repository

PENDING
heikkohoo/5w-logger

Shared repository data · GitHub

License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 20:40 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package_version:490fc996d8df561dcebd4e9f8caaa7401ab0364fa381d55012a545f96be284e9

Other collected versions

1.0.42 Oct1.0.25 Jun1.0.17 May1.0.030 MarView all collected versions →