Software: Apache/2.4.41 (Ubuntu). PHP/8.0.30 uname -a: Linux apirnd 5.4.0-204-generic #224-Ubuntu SMP Thu Dec 5 13:38:28 UTC 2024 x86_64 uid=33(www-data) gid=33(www-data) groups=33(www-data) Safe-mode: OFF (not secure) /usr/local/lib/node_modules/strapi/node_modules/pino/test/ drwxr-xr-x | |
| Viewing file: Select action/file-type: 'use strict'
var test = require('tap').test
var os = require('os')
var pino = require('../')
var sink = require('./helper').sink
var pid = process.pid
var hostname = os.hostname()
test('metadata works', function (t) {
t.plan(7)
var dest = sink(function (chunk, enc, cb) {
t.ok(new Date(chunk.time) <= new Date(), 'time is greater than Date.now()')
delete chunk.time
t.deepEqual(chunk, {
pid: pid,
hostname: hostname,
level: 30,
hello: 'world',
msg: 'a msg',
v: 1
})
})
var now = Date.now()
var instance = pino({}, {
[Symbol.for('needsMetadata')]: true,
write: function (chunk) {
t.equal(instance, this.lastLogger)
t.equal(30, this.lastLevel)
t.equal('a msg', this.lastMsg)
t.ok(Number(this.lastTime) >= now)
t.deepEqual({ hello: 'world' }, this.lastObj)
dest.write(chunk)
}
})
instance.info({ hello: 'world' }, 'a msg')
})
test('child loggers works', function (t) {
t.plan(6)
var dest = sink(function (chunk, enc, cb) {
t.ok(new Date(chunk.time) <= new Date(), 'time is greater than Date.now()')
delete chunk.time
t.deepEqual(chunk, {
pid: pid,
hostname: hostname,
level: 30,
hello: 'world',
from: 'child',
msg: 'a msg',
v: 1
})
})
var instance = pino({}, {
[Symbol.for('needsMetadata')]: true,
write: function (chunk) {
t.equal(child, this.lastLogger)
t.equal(30, this.lastLevel)
t.equal('a msg', this.lastMsg)
t.deepEqual({ from: 'child' }, this.lastObj)
dest.write(chunk)
}
})
var child = instance.child({ hello: 'world' })
child.info({ from: 'child' }, 'a msg')
})
test('without object', function (t) {
t.plan(6)
var dest = sink(function (chunk, enc, cb) {
t.ok(new Date(chunk.time) <= new Date(), 'time is greater than Date.now()')
delete chunk.time
t.deepEqual(chunk, {
pid: pid,
hostname: hostname,
level: 30,
msg: 'a msg',
v: 1
})
})
var instance = pino({}, {
[Symbol.for('needsMetadata')]: true,
write: function (chunk) {
t.equal(instance, this.lastLogger)
t.equal(30, this.lastLevel)
t.equal('a msg', this.lastMsg)
t.equal(null, this.lastObj)
dest.write(chunk)
}
})
instance.info('a msg')
})
test('without msg', function (t) {
t.plan(6)
var dest = sink(function (chunk, enc, cb) {
t.ok(new Date(chunk.time) <= new Date(), 'time is greater than Date.now()')
delete chunk.time
t.deepEqual(chunk, {
pid: pid,
hostname: hostname,
level: 30,
hello: 'world',
v: 1
})
})
var instance = pino({}, {
[Symbol.for('needsMetadata')]: true,
write: function (chunk) {
t.equal(instance, this.lastLogger)
t.equal(30, this.lastLevel)
t.equal(undefined, this.lastMsg)
t.deepEqual({ hello: 'world' }, this.lastObj)
dest.write(chunk)
}
})
instance.info({ hello: 'world' })
})
|
:: Command execute :: | |
--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0051 ]-- |