Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@bogeychan/elysia-logger

Package Overview
Dependencies
Maintainers
1
Versions
34
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.0.8 to 0.0.9

6

dist/index.d.ts
import Elysia from 'elysia';
import type { LoggerOptions, FileLoggerOptions, StreamLoggerOptions } from './types';
export declare const logger: <ContextKeyName extends string = "log">(options?: StreamLoggerOptions<ContextKeyName>) => (app: Elysia) => Elysia<"", {
export declare const logger: <ContextKeyName extends string = "log">(options?: StreamLoggerOptions<ContextKeyName>) => Elysia<"", {
store: {};

@@ -14,3 +14,3 @@ error: {};

}>;
export declare const fileLogger: <ContextKeyName extends string = "log">(options: FileLoggerOptions<ContextKeyName>) => (app: Elysia) => Elysia<"", {
export declare const fileLogger: <ContextKeyName extends string = "log">(options: FileLoggerOptions<ContextKeyName>) => Elysia<"", {
store: {};

@@ -26,4 +26,4 @@ error: {};

}>;
export declare function createPinoLogger<ContextKeyName extends string>(options?: Omit<LoggerOptions<ContextKeyName>, 'customProps' | 'contextKeyName'>): import("pino").Logger<Omit<LoggerOptions<ContextKeyName>, "customProps" | "contextKeyName">>;
export declare function createPinoLogger<ContextKeyName extends string = string>(options?: Omit<LoggerOptions<ContextKeyName>, 'customProps' | 'contextKeyName'>): import("pino").Logger<Omit<LoggerOptions<ContextKeyName>, "customProps" | "contextKeyName">>;
export * from './config';
export type { ElysiaContextForInstance, InferElysiaInstance } from './types';
import pino from 'pino';
import Elysia from 'elysia';
import { formatters, serializers } from './config';

@@ -27,3 +28,5 @@ export const logger = (options = {}) => plugin(options);

const { contextKeyName, ...loggerOptions } = options;
return (app) => app.derive((ctx) => {
return new Elysia({
name: '@bogeychan/elysia-logger'
}).derive((ctx) => {
let log = createPinoLogger(loggerOptions);

@@ -30,0 +33,0 @@ if (typeof options.customProps === 'function') {

/// <reference types="bun-types" />
import type { pino } from 'pino';
import type { Context, Elysia, ElysiaInstance } from 'elysia';
import type { DestinationStream, LoggerOptions as PinoLoggerOptions, pino } from 'pino';
export type StreamLoggerOptions<ContextKeyName extends string> = BaseLoggerOptions<ContextKeyName> & {
stream?: DestinationStream;
stream?: pino.DestinationStream;
};

@@ -11,3 +11,3 @@ export type FileLoggerOptions<ContextKeyName extends string> = BaseLoggerOptions<ContextKeyName> & {

export type LoggerOptions<ContextKeyName extends string> = StreamLoggerOptions<ContextKeyName> | FileLoggerOptions<ContextKeyName>;
type BaseLoggerOptions<ContextKeyName extends string> = Omit<PinoLoggerOptions, 'level'> & {
type BaseLoggerOptions<ContextKeyName extends string> = Omit<pino.LoggerOptions, 'level'> & {
level?: pino.LevelWithSilent | (string & {});

@@ -17,4 +17,5 @@ contextKeyName?: ContextKeyName;

};
export type Logger = pino.Logger;
export type InferElysiaInstance<T> = T extends Elysia<infer _BasePath, infer U> ? U : never;
export type ElysiaContextForInstance<Instance extends ElysiaInstance> = Context<Instance['schema'], Instance['store']> & Partial<Instance['request']>;
export {};
{
"name": "@bogeychan/elysia-logger",
"version": "0.0.8",
"version": "0.0.9",
"description": "A plugin for Elysia.js for logging using the pino library",

@@ -17,6 +17,12 @@ "author": {

"exports": {
"require": "./dist/index.js",
"import": "./dist/index.js",
"node": "./dist/index.js",
"default": "./dist/index.js"
".": {
"require": "./dist/index.js",
"import": "./dist/index.js",
"node": "./dist/index.js",
"default": "./dist/index.js",
"types": "./dist/index.d.ts"
},
"./types": {
"types": "./dist/types.d.ts"
}
},

@@ -23,0 +29,0 @@ "types": "./src/index.ts",

@@ -37,3 +37,3 @@ import pino from 'pino';

*/
export function createPinoLogger<ContextKeyName extends string>(
export function createPinoLogger<ContextKeyName extends string = string>(
options: Omit<

@@ -80,5 +80,7 @@ LoggerOptions<ContextKeyName>,

return (app: Elysia) =>
return new Elysia({
name: '@bogeychan/elysia-logger'
}).derive<DeriveReturned>(
// @ts-ignore
app.derive<DeriveReturned>((ctx) => {
(ctx) => {
let log = createPinoLogger(loggerOptions);

@@ -94,3 +96,4 @@

};
});
}
);
}

@@ -97,0 +100,0 @@

@@ -0,7 +1,3 @@

import type { pino } from 'pino';
import type { Context, Elysia, ElysiaInstance } from 'elysia';
import type {
DestinationStream,
LoggerOptions as PinoLoggerOptions,
pino
} from 'pino';

@@ -13,3 +9,3 @@ /**

BaseLoggerOptions<ContextKeyName> & {
stream?: DestinationStream;
stream?: pino.DestinationStream;
};

@@ -33,3 +29,3 @@

type BaseLoggerOptions<ContextKeyName extends string> = Omit<
PinoLoggerOptions,
pino.LoggerOptions,
'level'

@@ -69,2 +65,4 @@ > & {

export type Logger = pino.Logger;
export type InferElysiaInstance<T> = T extends Elysia<infer _BasePath, infer U>

@@ -71,0 +69,0 @@ ? U

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