pino-colada
Advanced tools
Comparing version 1.6.0 to 1.6.1
#! /usr/bin/env node | ||
var split = require('split2') | ||
var pinoColada = require('./')() | ||
@@ -8,3 +7,3 @@ var input = process.stdin | ||
input | ||
.pipe(split(pinoColada)) | ||
.pipe(pinoColada) | ||
.pipe(output) |
30
index.js
@@ -5,2 +5,3 @@ var prettyBytes = require('prettier-bytes') | ||
var padLeft = require('pad-left') | ||
var split = require('split2') | ||
var chalk = require('chalk') | ||
@@ -22,30 +23,13 @@ var nl = '\n' | ||
function isObject (input) { | ||
return Object.prototype.toString.apply(input) === '[object Object]' | ||
} | ||
function isPinoLog (log) { | ||
return log && (log.hasOwnProperty('v') && log.v === 1) | ||
} | ||
module.exports = PinoColada | ||
function PinoColada () { | ||
return parse | ||
return split(parse) | ||
function parse (inputData) { | ||
var obj | ||
if (typeof inputData === 'string') { | ||
var parsedData = jsonParse(inputData) | ||
if (!parsedData.value || parsedData.err || !isPinoLog(parsedData.value)) { | ||
return inputData + nl | ||
} | ||
obj = parsedData.value | ||
} else if (isObject(inputData) && isPinoLog(inputData)) { | ||
obj = inputData | ||
} else { | ||
return inputData + nl | ||
} | ||
function parse (line) { | ||
var obj = jsonParse(line) | ||
if (!obj.value || obj.err) return line + nl | ||
obj = obj.value | ||
if (!obj.level) return inputData + nl | ||
if (!obj.level) return line + nl | ||
if (!obj.message) obj.message = obj.msg | ||
@@ -52,0 +36,0 @@ if (typeof obj.level === 'number') convertLogNumber(obj) |
{ | ||
"name": "pino-colada", | ||
"version": "1.6.0", | ||
"version": "1.6.1", | ||
"description": "cute ndjson logger for pino", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -21,13 +21,2 @@ # pino-colada 🍹 | ||
# Programmatic integration as [pino prettifier](http://getpino.io/#/docs/pretty?id=api-example) | ||
```javascript | ||
const pino = require('pino') | ||
const logger = pino({ | ||
prettifier: require('pino-colada') | ||
}) | ||
logger.info('hi') | ||
``` | ||
# Install | ||
@@ -34,0 +23,0 @@ ```bash |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
0
56474
209
45