Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade module #12

Merged
merged 4 commits into from
Sep 21, 2021
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
36 changes: 36 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: CI
on:
push:
paths-ignore:
- '*.md'
pull_request:
paths-ignore:
- '*.md'
jobs:
test:
name: ${{ matrix.node-version }} ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
node-version: [12, 14, 16]
steps:
- uses: actions/checkout@v2.3.4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2.4.0
with:
node-version: ${{ matrix.node-version }}
- name: Install
run: npm i
- name: Tests
run: npm test

automerge:
needs: test
runs-on: ubuntu-latest
steps:
- uses: fastify/github-action-merge-dependabot@v2.5.0
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
target: minor
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,5 @@ Icon
Network Trash Folder
Temporary Items
.apdisk

package-lock.json
4 changes: 2 additions & 2 deletions lib/rfc3164.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function buildMessage (data, headerBytes) {
}

if (options.includeProperties.length > 0) {
options.includeProperties.map((p) => { message[p] = data[p] })
options.includeProperties.forEach((p) => { message[p] = data[p] })
message = stringify(message)
} else {
message = stringify(data)
Expand Down Expand Up @@ -44,7 +44,7 @@ module.exports = function ($options) {
if (timestamp[4] === '0') {
timestamp = timestamp.substr(0, 4) + ' ' + timestamp.substr(5)
}
const hostname = data.hostname.split('.')[ 0 ]
const hostname = data.hostname.split('.')[0]
const header = `<${pri}>${timestamp} ${hostname} ${options.appname}[${data.pid}]: `
const message = buildMessage(data, header.length)
let output = (options.cee && !options.messageOnly) ? `${header}@cee: ${message}` : `${header}${message}`
Expand Down
2 changes: 1 addition & 1 deletion lib/rfc5424.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function buildMessage (data) {
}

if (options.includeProperties.length > 0) {
options.includeProperties.map((p) => { message[p] = data[p] })
options.includeProperties.forEach((p) => { message[p] = data[p] })
message = stringify(message)
} else {
message = stringify(data)
Expand Down
4 changes: 2 additions & 2 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ function levelToSeverity (level) {
case 50: // pino: error
result = severity.error
break
default:
case 60: // pino: fatal
default:
result = severity.critical
break
}
return result
}

module.exports = {severity, levelToSeverity}
module.exports = { severity, levelToSeverity }
17 changes: 9 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
"homepage": "https://github.com/pinojs/pino-syslog",
"main": "psyslog.js",
"scripts": {
"test": "tap --no-cov 'test/**/*.test.js'",
"lint": "standard"
"test": "npm run lint && tap --no-cov 'test/**/*.test.js'",
"lint": "standard",
"lint:fix": "standard --fix"
},
"bin": {
"pino-syslog": "./app.js"
Expand All @@ -29,16 +30,16 @@
"devDependencies": {
"istanbul": "^0.4.5",
"pre-commit": "^1.2.2",
"standard": "^10.0.2",
"tap": "^11.0.1"
"standard": "^16.0.3",
"tap": "^15.0.9"
},
"dependencies": {
"fast-json-parse": "^1.0.2",
"fast-safe-stringify": "^2.0.2",
"moment-timezone": "^0.5.13",
"nopt": "^4.0.1",
"pump": "^2.0.1",
"split2": "^2.1.1",
"through2": "^2.0.3"
"nopt": "^5.0.0",
"pump": "^3.0.0",
"split2": "^3.2.2",
"through2": "^4.0.2"
}
}
2 changes: 1 addition & 1 deletion psyslog.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ if (args.config) {
}
}

const options = Object.assign({}, defaults, jsonOptions, args);
const options = Object.assign({}, defaults, jsonOptions, args)

let myTransport
if (options.modern) {
Expand Down
26 changes: 13 additions & 13 deletions test/3164.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ test('skips non-json input', (t) => {
})

psyslog.on('close', (code) => {
t.is(code, 0)
t.equal(code, 0)
})

psyslog.stdin.end('this is not json\n')
Expand All @@ -33,7 +33,7 @@ test('returns error for overly long rfc3164 messages', (t) => {

psyslog.stdout.on('data', (data) => {
const msg = data.toString()
t.is(msg, expected)
t.equal(msg, expected)
psyslog.kill()
})

Expand All @@ -47,7 +47,7 @@ test('formats to message only', (t) => {

psyslog.stdout.on('data', (data) => {
const msg = data.toString()
t.is(msg, expected)
t.equal(msg, expected)
psyslog.kill()
})

Expand All @@ -61,7 +61,7 @@ test('sets application name', (t) => {

psyslog.stdout.on('data', (data) => {
const msg = data.toString()
t.is(msg, expected)
t.equal(msg, expected)
psyslog.kill()
})

Expand All @@ -75,7 +75,7 @@ test('sets facility', (t) => {

psyslog.stdout.on('data', (data) => {
const msg = data.toString()
t.is(msg, expected)
t.equal(msg, expected)
psyslog.kill()
})

Expand All @@ -89,7 +89,7 @@ test('format timestamp with leading zero in days', (t) => {

psyslog.stdout.on('data', (data) => {
const msg = data.toString()
t.is(msg, expected)
t.equal(msg, expected)
psyslog.kill()
})

Expand All @@ -103,7 +103,7 @@ test('format timestamp with trailing zero in days', (t) => {

psyslog.stdout.on('data', (data) => {
const msg = data.toString()
t.is(msg, expected)
t.equal(msg, expected)
psyslog.kill()
})

Expand All @@ -117,7 +117,7 @@ test('sets timezone', (t) => {

psyslog.stdout.on('data', (data) => {
const msg = data.toString()
t.is(msg, expected)
t.equal(msg, expected)
psyslog.kill()
})

Expand All @@ -131,7 +131,7 @@ test('prepends `@cee `', (t) => {

psyslog.stdout.on('data', (data) => {
const msg = data.toString()
t.is(msg, header + messages.helloWorld)
t.equal(msg, header + messages.helloWorld)
psyslog.kill()
})

Expand All @@ -145,7 +145,7 @@ test('does not prepend `@cee ` for non-json messages', (t) => {

psyslog.stdout.on('data', (data) => {
const msg = data.toString()
t.is(msg, expected)
t.equal(msg, expected)
psyslog.kill()
})

Expand All @@ -159,7 +159,7 @@ test('truncates overly long message only log', (t) => {

psyslog.stdout.on('data', (data) => {
const msg = data.toString()
t.is(msg, expected)
t.equal(msg, expected)
psyslog.kill()
})

Expand All @@ -169,11 +169,11 @@ test('truncates overly long message only log', (t) => {
test('appends newline', (t) => {
t.plan(1)
const expected = '<134>Apr 1 16:44:58 MacBook-Pro-3 none[94473]: ' + messages.helloWorld + '\n'
const psyslog = spawn('node', [ psyslogPath, '-c', configPath('3164', 'newline.json') ])
const psyslog = spawn('node', [psyslogPath, '-c', configPath('3164', 'newline.json')])

psyslog.stdout.on('data', (data) => {
const msg = data.toString()
t.is(msg, expected)
t.equal(msg, expected)
psyslog.kill()
})

Expand Down
24 changes: 12 additions & 12 deletions test/5424.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ test('skips non-json input', (t) => {
})

psyslog.on('close', (code) => {
t.is(code, 0)
t.equal(code, 0)
})

psyslog.stdin.end('this is not json\n')
Expand All @@ -33,7 +33,7 @@ test('hello world', (t) => {

psyslog.stdout.on('data', (data) => {
const msg = data.toString()
t.is(msg, header + messages.helloWorld)
t.equal(msg, header + messages.helloWorld)
psyslog.kill()
})

Expand All @@ -47,7 +47,7 @@ test('formats to message only', (t) => {

psyslog.stdout.on('data', (data) => {
const msg = data.toString()
t.is(msg, expected)
t.equal(msg, expected)
psyslog.kill()
})

Expand All @@ -61,7 +61,7 @@ test('sets application name', (t) => {

psyslog.stdout.on('data', (data) => {
const msg = data.toString()
t.is(msg, expected)
t.equal(msg, expected)
psyslog.kill()
})

Expand All @@ -75,7 +75,7 @@ test('sets facility', (t) => {

psyslog.stdout.on('data', (data) => {
const msg = data.toString()
t.is(msg, expected)
t.equal(msg, expected)
psyslog.kill()
})

Expand All @@ -89,7 +89,7 @@ test('sets timezone', (t) => {

psyslog.stdout.on('data', (data) => {
const msg = data.toString()
t.is(msg, expected)
t.equal(msg, expected)
psyslog.kill()
})

Expand All @@ -103,7 +103,7 @@ test('prepends `@cee `', (t) => {

psyslog.stdout.on('data', (data) => {
const msg = data.toString()
t.is(msg, header + messages.helloWorld)
t.equal(msg, header + messages.helloWorld)
psyslog.kill()
})

Expand All @@ -117,7 +117,7 @@ test('does not prepend `@cee ` for non-json messages', (t) => {

psyslog.stdout.on('data', (data) => {
const msg = data.toString()
t.is(msg, expected)
t.equal(msg, expected)
psyslog.kill()
})

Expand All @@ -127,11 +127,11 @@ test('does not prepend `@cee ` for non-json messages', (t) => {
test('appends newline', (t) => {
t.plan(1)
const expected = '<134>1 2016-04-01T16:44:58Z MacBook-Pro-3 - 94473 - - ' + messages.helloWorld + '\n'
const psyslog = spawn('node', [ psyslogPath, '-c', configPath('5424', 'newline.json') ])
const psyslog = spawn('node', [psyslogPath, '-c', configPath('5424', 'newline.json')])

psyslog.stdout.on('data', (data) => {
const msg = data.toString()
t.is(msg, expected)
t.equal(msg, expected)
psyslog.kill()
})

Expand All @@ -141,11 +141,11 @@ test('appends newline', (t) => {
test('uses structured data', (t) => {
t.plan(1)
const expected = '<134>1 2016-04-01T16:44:58Z MacBook-Pro-3 - 94473 - [a@b x="y"] ' + messages.helloWorld
const psyslog = spawn('node', [ psyslogPath, '-c', configPath('5424', 'structuredData.json') ])
const psyslog = spawn('node', [psyslogPath, '-c', configPath('5424', 'structuredData.json')])

psyslog.stdout.on('data', (data) => {
const msg = data.toString()
t.is(msg, expected)
t.equal(msg, expected)
psyslog.kill()
})

Expand Down