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

logestic

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

logestic

An advanced and customisable logging library for ElysiaJS

  • 0.1.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

Logestic

An advanced and customisable logging library for ElysiaJS

Table of Contents

  • Logestic
  • Table of Contents
  • Installation
  • Usage
  • Contributing Guidelines
  • License
  • Authors

Installation

Add the package with your favourite package manager to your Elysia Project.

  npm install --save logestic

  # or
  yarn add logestic

  # or
  pnpm add logestic

  # or
  bun add logestic

Note: You must have elysia@1.0 installed in your project.

Usage

There are two ways to add logging to your Elysia application.

Preset request logging

Currently there are these presets availble to use.

import { Elysia } from 'elysia';
import { Logestic } from 'logestic';

const app = new Elysia()
  .use(Logestic.preset('common'))
  .get('/', () => "Hello from server")
  .listen(5566);

Custom request logging

If you don't like any of presets, you can configure Logestic to log your requests in your way.

  1. Create a Logestic instance, optionally where you wish to log.
  2. Call use to tell Logestic the information you wish to use.
  3. Finally, create an Elysia instance on custom with the formating function.
// ./logger.ts
import { Logestic } from 'logestic';

const fileLogger = (msg: string) => {
  const logFile = Bun.file('requests.log');
  const writer = logFile.writer();

  writer.write(msg);
  writer.flush();
}

// exports an Elysia instance
export new Logestic(fileLogger)
  .use(['method', 'path', 'time', 'status'])
  .custom(({ method, path, time, status }) => {
    return `[${time}]: ${method} ${path} | ${status}`
  })


// ./index.ts
import myLogger from './logger'

const app = new Elysia()
  .use(myLogger)
  .get('/', () => "Hello from server")
  .listen(5566);

Consider contibuting your own preset; check contributing guidelines.

Contributing Guidelines

See CONTRIBUTING.md

License

MIT

Authors

Keywords

FAQs

Package last updated on 17 Mar 2024

Did you know?

Socket

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.

Install

Related posts

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