Security News
pnpm 10.0.0 Blocks Lifecycle Scripts by Default
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
@bogeychan/elysia-logger
Advanced tools
A plugin for Elysia.js for logging using the pino library.
bun add @bogeychan/elysia-logger
import { Elysia } from "elysia";
import { logger } from "@bogeychan/elysia-logger";
const app = new Elysia()
.use(
logger({
level: "error",
})
)
.get("/", (ctx) => {
ctx.log.error(ctx, "Context");
ctx.log.info(ctx.request, "Request"); // noop
return "Hello World";
})
.listen(8080);
console.log(`Listening on ${app.server!.url}`);
import { fileLogger } from "@bogeychan/elysia-logger";
fileLogger({
file: "./my.log",
});
import { logger } from '@bogeychan/elysia-logger';
logger({
stream: ... // default -> console output
});
import { logger, type InferContext } from "@bogeychan/elysia-logger";
const myPlugin = () => new Elysia().decorate("myProperty", 42);
// ...
app = app.use(myPlugin());
app
.use(
logger({
/**
* This function will be invoked for each `log`-method called
* where you can pass additional properties that need to be logged
*/
customProps(ctx: InferContext<typeof app>) {
return {
params: ctx.params,
query: ctx.query,
myProperty: ctx.myProperty,
};
},
})
)
.get("/", (ctx) => {
ctx.log.info(ctx, "Context");
return "with-context";
});
Standalone
and inside Context
import { createPinoLogger } from "@bogeychan/elysia-logger";
const log = createPinoLogger(/* ... */);
app
.use(log.into(/* ... */))
.onError((ctx) => {
log.error(ctx, ctx.error.name);
return "onError";
})
.get("/", (ctx) => {
ctx.log.info(ctx, "Context");
throw { message: "1234", name: "MyError" };
});
onResponse
logging by default
; based on pino-httpimport { logger } from "@bogeychan/elysia-logger";
app
.use(
logger({
autoLogging: true, // default
autoLogging: false, // disabled
autoLogging: {
ignore(ctx) {
return true; // ignore logging for requests based on condition
},
},
})
)
.get("/", (ctx) => "autoLogging");
Checkout the examples folder on github for further use cases such as the integration of pino-pretty for readable console outputs.
0.0.22 - 24 Mai 2024
Improvement:
pino
to 9.1.0
FAQs
A plugin for Elysia.js for logging using the pino library
The npm package @bogeychan/elysia-logger receives a total of 6,685 weekly downloads. As such, @bogeychan/elysia-logger popularity was classified as popular.
We found that @bogeychan/elysia-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.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.