New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@bogeychan/elysia-logger

Package Overview
Dependencies
Maintainers
1
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bogeychan/elysia-logger - npm Package Compare versions

Comparing version 0.1.7 to 0.1.8

bun.lock

13

dist/config/formatters.js

@@ -9,4 +9,13 @@ import { serializeRequest } from "./serializers.js";

if (object.isError) {
log.code = object.code;
log.message = object.error.message;
const { code, error } = object;
log.code = code;
if ("message" in error) {
log.message = error.message;
}
else if ("code" in error && "response" in error) {
log.message = `HTTP ${error.code}: ${error.response}`;
}
else {
log.message = "Unknown error";
}
}

@@ -13,0 +22,0 @@ else {

import { pino } from "pino";
import { Elysia } from "elysia";
import type { Logger, ElysiaLogger, StandaloneLoggerOptions, ElysiaFileLoggerOptions, ElysiaStreamLoggerOptions, _INTERNAL_Writeonly, _INTERNAL_ElysiaLoggerPlugin, _INTERNAL_ElysiaLoggerPluginAutoLoggingState, _INTERNAL_ElysiaLoggerPluginAutoLoggingEnabledOptions, _INTERNAL_ElysiaLoggerPluginAutoLoggingDisabledOptions } from "./types.js";
import type { Logger, ElysiaLogger, ElysiaLoggerOptions, StandaloneLoggerOptions, ElysiaFileLoggerOptions, ElysiaStreamLoggerOptions, _INTERNAL_Writeonly, _INTERNAL_ElysiaLoggerPlugin, _INTERNAL_ElysiaLoggerPluginAutoLoggingState, _INTERNAL_ElysiaLoggerPluginAutoLoggingEnabledOptions, _INTERNAL_ElysiaLoggerPluginAutoLoggingDisabledOptions } from "./types.js";
/**

@@ -14,6 +14,8 @@ * The StreamLogger is used to write log entries to a stream such as the console output (default behavior).

export declare function fileLogger(options: _INTERNAL_ElysiaLoggerPluginAutoLoggingDisabledOptions<ElysiaFileLoggerOptions>): _INTERNAL_ElysiaLoggerPlugin;
type ElysiaLoggerInstance = ElysiaLogger<ReturnType<typeof into>>;
/**
* Create a logger instance like the plugin.
*/
export declare function createPinoLogger(options?: StandaloneLoggerOptions): ElysiaLogger<Elysia<"", {
export declare function createPinoLogger(options?: StandaloneLoggerOptions): ElysiaLoggerInstance;
export declare function wrap(logger: Logger, options?: ElysiaLoggerOptions): Elysia<"", {
decorator: {};

@@ -64,5 +66,52 @@ store: {};

schema: {};
}>>;
}>;
declare function into(this: Logger, options?: ElysiaLoggerOptions): Elysia<"", {
decorator: {};
store: {};
derive: {
readonly log: pino.Logger<never, boolean>;
};
resolve: {};
}, {
typebox: import("@sinclair/typebox").TModule<{}>;
error: {};
}, {
schema: {};
macro: {};
macroFn: {};
parser: {};
}, {}, {
derive: {};
resolve: {};
schema: {};
}, {
derive: {};
resolve: {};
schema: {};
}> | Elysia<"", {
decorator: {};
store: _INTERNAL_Writeonly<_INTERNAL_ElysiaLoggerPluginAutoLoggingState>;
derive: {
readonly log: Logger;
};
resolve: {};
}, {
typebox: import("@sinclair/typebox").TModule<{}>;
error: {};
}, {
schema: import("elysia").MergeSchema<import("elysia").MergeSchema<{}, {}, "">, {}, "">;
macro: {};
macroFn: {};
parser: {};
}, {}, {
derive: {};
resolve: {};
schema: {};
}, {
derive: {};
resolve: {};
schema: {};
}>;
export * from "./config/index.js";
export type { InferContext } from "./types.js";
export { pino } from "pino";

@@ -38,2 +38,5 @@ import { pino } from "pino";

}
export function wrap(logger, options = {}) {
return into.bind(logger)(options);
}
function into(options = {}) {

@@ -40,0 +43,0 @@ const useLevel = options.useLevel ?? "info";

10

package.json
{
"name": "@bogeychan/elysia-logger",
"version": "0.1.7",
"version": "0.1.8",
"description": "A plugin for Elysia.js for logging using the pino library",

@@ -37,10 +37,10 @@ "author": {

"peerDependencies": {
"elysia": ">= 1.2.2"
"elysia": ">= 1.2.10"
},
"devDependencies": {
"@types/bun": "^1.1.14",
"elysia": "1.2.2",
"@types/bun": "^1.2.0",
"elysia": "1.2.10",
"pino-pretty": "^13.0.0",
"tsd": "^0.31.2",
"typescript": "^5.7.2"
"typescript": "^5.7.3"
},

@@ -47,0 +47,0 @@ "dependencies": {

@@ -31,3 +31,3 @@ # @bogeychan/elysia-logger

})
.listen(8080);
.listen(3000);

@@ -126,2 +126,23 @@ console.log(`Listening on ${app.server!.url}`);

### Use existing `pino` logger
```ts
import { pino } from "pino";
import { wrap } from "@bogeychan/elysia-logger";
const logger = pino(/* ... */);
app
.use(
wrap(logger, {
/* ... */
})
)
.get("/", (ctx) => {
ctx.log.info(ctx, "Context");
return "wrapped!";
});
```
### Automatic `onAfterResponse` & `onError` logging by `default`; based on [pino-http](https://github.com/pinojs/pino-http)

@@ -128,0 +149,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc