technicallyjosh / pino-http-send Goto Github PK
View Code? Open in Web Editor NEWA basic PinoJS http(s) transport with batching!
A basic PinoJS http(s) transport with batching!
Can we add an option to allow self signed certificates?
We are need to use HTTPS for testing.
Perhaps a new arg like allowInsecureHttps
In send.ts
got(url, {
method: method as Method,
...
https: {
rejectUnauthorized: !allowInsecureHttps,
},
...createBody(logs, bodyType as BodyType),
})
.option('allowInsecureHttps', {
alias: 'n',
type: 'boolean',
desc: 'if SSL certificates must be verified by a trusted authority',
group: 'Sending',
default: false,
})
Would like to send the logs to different URL's based on environment variable.
E.g. PINO_HTTP_SEND_URL
rather than having to pass it in as an argument.
I'm trying to send logs to and endpoint and optional pass also to the stadout when is needed...
But i'm getting the following error
See my current config:
....................................................................................................................................................................index.js
"use strict";
// see docs https://github.com/pinojs/pino/blob/master/docs/pretty.md *prod
// https://www.npmjs.com/package/pino-transmit-http/v/1.0.0-alpha.3
// see docs https://github.com/pinojs/pino-pretty *dev
const Hapi = require("@hapi/hapi");
//const {createWriteStream} = require('pino-http-send');
const pino = require('pino');
const hapiPino = require('hapi-pino');
const getResponse = [
{ string: "string1", number: 1, boolean: true },
{ string: "string2", number: 2, boolean: false }
];
async function start() {
// Create a server with a host and port
const server = Hapi.server({
host: "localhost",
port: 3000,
debug: false // disable Hapi debug console logging
});
// Add the route
server.route({
method: "GET",
path: "/items",
options: {
log: { collect: true },
cache: { expiresIn: 5000 },
handler: async function (request, h) {
try {
// you can also use a pino instance, which will be faster
request.logger.info('GET_items', getResponse)
return h.response(getResponse);
} catch (err) {
console.log(err);
return request.logger.error('GET_error', err)
}
}
}
});
await server.register({
plugin: hapiPino,
options: {
instance: pino()
// {
// level: 'info',
// stream: createWriteStream({
// url: 'http://localhost:3000'
// })
// })
}
});
await server.start();
server.log(["SERVER_INFO"], `server running: ${server.info.uri}/items`);
return server;
}
start().catch((err) => {
console.log(err);
process.exit(1);
});
....................................................................................................................................................................package.json
{
"name": "pino-example",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "PINO_HTTP_SEND_url=http://localhost:3000 node . | pino-http-send --url=http://localhost:3000"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"@hapi/hapi": "^20.2.1",
"hapi-pino": "^9.1.0",
"pino-http-send": "^0.4.2"
}
}
What i'm missing here? How can i see the logs in some endpoint? Where i can/need to configure that endpoint?
Hello Thanks for this awesome lib.
after installing it i'm facing this error (nuxt), any taught ?
WARN Compiled with 2 warnings
WARN in ./node_modules/yargs/index.js
Critical dependency: require function is used in a way in which dependencies cannot be statically extracted
WARN in ./node_modules/yargs/build/lib/apply-extends.js
Critical dependency: the request of a dependency is an expression
ERROR Failed to compile with 14 errors
These dependencies were not found:
* dns in ./node_modules/cacheable-lookup/source/index.js
* fs in ./node_modules/got/dist/source/core/index.js, ./node_modules/got/dist/source/core/utils/get-body-size.js and 6 others
* http2 in ./node_modules/http2-wrapper/source/index.js
* net in ./node_modules/got/dist/source/core/utils/timed-out.js, ./node_modules/http2-wrapper/source/utils/calculate-server-name.js
* tls in ./node_modules/http2-wrapper/source/agent.js, ./node_modules/resolve-alpn/index.js
* To install them, you can run: npm install --save dns fs http2 net tls
Any plans to support v7+ Transports ?
Does not work when installed locally using npm i pino-http-send
Gives the following error on RHEL7:
bash: pino-http-send: command not found
And the following on Windows:
'pino-http-send' is not recognized as an internal or external command,
operable program or batch file.
I have set the option "log: true" but I get nothing in stdout.
// my logger code
const pino = require('pino');
const { createWriteStream } = require('pino-http-send');
const stream = createWriteStream({
url: process.env.LOGS_DESTINATION_URL,
log: true,
silent: false,
timeout: 0,
});
const logger = pino(stream);
module.exports = logger;
I don't think this is currently supported, but it would be neat if we could use this library programmatically as a module.
The LogFlare module might be a good starting point on how to do this, but essentially you would want something like:
import { createWriteStream } from 'pino-http-send'
// create stream w/ options
const stream = createWriteStream({
url: "https://example.com/logging"
});
// create pino loggger
const logger = pino({
level: 'info
}, stream);
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.