Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@ updates:
commit-message:
prefix: 'chore'
include: 'scope'
cooldown:
default-days: 5
- package-ecosystem: 'npm'
directory: '/'
schedule:
interval: 'daily'
commit-message:
prefix: 'chore'
include: 'scope'
cooldown:
default-days: 5
38 changes: 15 additions & 23 deletions .github/workflows/test-and-release.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: Test & Maybe Release
on: [push, pull_request]

jobs:
test:
strategy:
Expand All @@ -10,55 +11,46 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- name: Checkout Repository
uses: actions/checkout@v6.0.2
uses: actions/checkout@v6
- name: Use Node.js ${{ matrix.node }}
uses: actions/setup-node@v6.4.0
uses: actions/setup-node@v6
with:
node-version: ${{ matrix.node }}
- name: Install Dependencies
run: npm install --no-progress
- name: Check build is up to date
run: |
npm install --no-progress
npm run build
git diff --exit-code || (echo "::error::Build artifacts not committed. Run 'npm run build' and commit the changes." && exit 1)
- name: Run tests
run: |
npm test
run: npm test

release:
name: Release
needs: test
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
permissions:
contents: write
issues: write
pull-requests: write
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v6.0.2
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v6.4.0
uses: actions/setup-node@v6
with:
node-version: lts/*
registry-url: 'https://registry.npmjs.org'
- name: Install dependencies
run: |
npm install --no-progress --no-package-lock --no-save
run: npm install --no-progress --no-package-lock --no-save
- name: Build
run: |
npm run build
- name: Install plugins
run: |
npm install \
@semantic-release/commit-analyzer \
conventional-changelog-conventionalcommits \
@semantic-release/release-notes-generator \
@semantic-release/npm \
@semantic-release/github \
@semantic-release/git \
@semantic-release/changelog \
--no-progress --no-package-lock --no-save
run: npm run build
- name: Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_CONFIG_PROVENANCE: true
run: npx semantic-release

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
node_modules
package-lock.json
20 changes: 12 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

**A tiny JSON logger, optimised for speed and simplicity**

[![CI](https://github.com/rvagg/bole/actions/workflows/test-and-release.yml/badge.svg)](https://github.com/rvagg/bole/actions/workflows/test-and-release.yml)

[![NPM](https://nodei.co/npm/bole.svg?style=flat&data=n,v&color=blue)](https://nodei.co/npm/bole/)

Log JSON from within Node.js applications. The log format is obviously inspired by the excellent [Bunyan](https://github.com/trentm/node-bunyan) and is likely to be output-compatible in most cases. The difference is that **bole** aims for even more simplicity, supporting only the common-case basics.
Expand All @@ -14,25 +12,27 @@ Log JSON from within Node.js applications. The log format is obviously inspired

**mymodule.js**
```js
const log = require('bole')('mymodule')
import bole from 'bole'

const log = bole('mymodule')

module.exports.derp = () => {
export function derp () {
log.debug('W00t!')
log.info('Starting mymodule#derp()')
}
```

**main.js**
```js
const bole = require('bole')
const mod = require('./mymodule')
import bole from 'bole'
import { derp } from './mymodule.js'

bole.output({
level: 'info',
stream: process.stdout
})

mod.derp()
derp()
```

```text
Expand Down Expand Up @@ -82,10 +82,14 @@ If you require more sophisticated serialisation of your objects, then write a ut
The `logger` object returned by `bole(name)` is also a function that accepts a `name` argument. It returns a new logger whose name is the parent logger with the new name appended after a `':'` character. This is useful for splitting a logger up for grouping events. Consider the HTTP server case where you may want to group all events from a particular request together:

```js
import http from 'node:http'
import { randomUUID } from 'node:crypto'
import bole from 'bole'

const log = bole('server')

http.createServer((req, res) => {
req.log = log(uuid.v4()) // make a new sub-logger
req.log = log(randomUUID()) // make a new sub-logger
req.log.info(req)

//...
Expand Down
12 changes: 6 additions & 6 deletions bole.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
'use strict'
import _stringify from 'fast-safe-stringify'
import * as os from 'node:os'
import format from './format.js'

const _stringify = require('fast-safe-stringify')
const individual = require('individual')('$$bole', { fastTime: false }) // singleton
const format = require('./format')
// stash on globalThis so duplicate bole copies in a dep tree share one registry
const individual = (globalThis.$$bole ??= { fastTime: false })
const levels = 'debug info warn error'.split(' ')
const os = require('os')
const pid = process.pid
let hasObjMode = false
const scache = []
Expand Down Expand Up @@ -233,4 +233,4 @@ bole.setFastTime = function setFastTime (b) {
return bole
}

module.exports = bole
export default bole
6 changes: 2 additions & 4 deletions format.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// consider this a warning about getting obsessive about optimization

const utilformat = require('util').format
import { format as utilformat } from 'node:util'

function format (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16) {
export default function format (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16) {
if (a16 !== undefined) {
return utilformat(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16)
}
Expand Down Expand Up @@ -50,5 +50,3 @@ function format (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a1
}
return a1
}

module.exports = format
27 changes: 18 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,17 @@
"name": "bole",
"version": "5.0.29",
"description": "A tiny JSON logger",
"type": "module",
"main": "bole.js",
"exports": "./bole.js",
"engines": {
"node": ">=20"
},
"scripts": {
"lint": "standard",
"test": "npm run lint && node test.js",
"build": "true"
"build": "true",
"test:unit": "node --test test.js",
"test": "npm run lint && npm run test:unit"
},
"keywords": [
"logging",
Expand All @@ -19,15 +25,18 @@
"url": "https://github.com/rvagg/bole.git"
},
"dependencies": {
"fast-safe-stringify": "^2.0.7",
"individual": "^3.0.0"
"fast-safe-stringify": "^2.1.1"
},
"devDependencies": {
"bl": "^6.0.0",
"hyperquest": "^2.1.3",
"list-stream": "^2.0.0",
"standard": "^17.0.0",
"tape": "^5.5.3"
"@semantic-release/changelog": "^6.0.3",
"@semantic-release/commit-analyzer": "^13.0.1",
"@semantic-release/git": "^10.0.1",
"@semantic-release/github": "^12.0.6",
"@semantic-release/npm": "^13.1.5",
"@semantic-release/release-notes-generator": "^14.1.0",
"conventional-changelog-conventionalcommits": "^9.3.1",
"semantic-release": "^25.0.3",
"standard": "^17.1.2"
},
"release": {
"branches": [
Expand Down
Loading
Loading