Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
@fastify/one-line-logger
Advanced tools
@fastify/one-line-logger
helps you format fastify's log into a nice one line message:
YYYY-MM-dd HH:mm:ss.SSSTZ - <level> - <method> <route path> - <message>
A standard incoming request log line like:
{"level": 30,"time": 1660151282194,"pid": 1557,"hostname": "foo","reqId": "req-1","req": {"method": "GET","url": "/path","hostname": "localhost:8080","remoteAddress": "127.0.0.1"},"msg": "incoming request"}
Will format to:
2022-08-11 01:08:02.194+0100 - info - GET / - incoming request
npm i @fastify/one-line-logger
const server = fastify({
logger: {
transport: {
target: "@fastify/one-line-logger",
},
},
});
Colors are enabled by default when supported. To manually disable the colors you need to set the transport.colorize
option to false
. For more options check the colorette
docs.
const server = fastify({
logger: {
transport: {
target: "@fastify/one-line-logger",
colorize: false,
},
},
});
Custom levels could be used by passing it into logger opts
const server = fastify({
logger: {
transport: {
target: "@fastify/one-line-logger",
},
customLevels: {
foo: 35,
bar: 45,
},
},
});
server.get("/", (request, reply) => {
request.log.info("time to foobar");
request.log.foo("FOO!");
request.log.bar("BAR!");
reply.send({ foobar: true });
});
Custom levels colors could be used by passing it into logger opts. They can also overwrite the default level's colors. Check all the supported colors here.
const server = fastify({
logger: {
transport: {
target: "@fastify/one-line-logger",
colors: {
35: "bgYellow",
45: "magenta",
60: "bgRedBright" // overwriting the `fatal` log color
}
},
customLevels: {
foo: 35,
bar: 45,
},
},
});
server.get("/", (request, reply) => {
request.log.fatal("An error occured");
request.log.foo("FOO!");
request.log.bar("BAR!");
reply.send({ foobar: true });
});
MIT License
FAQs
A simple formatter for fastify's logs
The npm package @fastify/one-line-logger receives a total of 2,353 weekly downloads. As such, @fastify/one-line-logger popularity was classified as popular.
We found that @fastify/one-line-logger demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.