GithubHelp home page GithubHelp logo

skoshx / logpile Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 0.0 109 KB

🪵 A simple & tiny logging library with supercharged search features

Home Page: https://paka.dev/npm/logpile

License: MIT License

JavaScript 6.12% TypeScript 93.88%
extendable logger logging search simple tiny typescript utility

logpile's Introduction

🪵 A simple & tiny logging library with supercharged search features

license CI prettier jest PRs Welcome Docs

Logs are an integral part of building good software, especially APIs. It's important for logs to be easy to write in code, and easy to connect to some larger entity. This is where logpile comes in. This library is perfect for needing a versatile logger that works for anything, and that can flexibly search logs.

A perfect example is an API, where errors are logged with a reference to the users account. You can use logpile to search for all the error logs associated with that user, and display them to the API user.

Install

$ yarn add logpile

or with npm

$ npm install --save logpile

Features

  • Tiny, Simple & Extendable
  • Extendable output medium (stdout, file, database or custom)
  • Supercharged search features (text, object, fuzzy)
  • Hides sensitive values from the logs
  • Fully TypeScript

Usage

import { createLogger } from 'logpile';

const logger = createLogger({
  persist: [consolePersist({ level: 'error' }), filePersist()],
  retrieve: fileRetrieve(),
});

// you can pass anything to the function
logger.warn('hello world', { some: 'object' }, 'another message');
/*=> {
  timestamp: "2022-05-13T01:19:18.402Z",
  level: "warning",
  message: "hello world",
  message2: "another message",
  some: "object"
}*/

// you can search all logs with useful features
// search logs containing value 'hello world', in the last hour

/**
 * You can search all logs with useful features.
 * Search logs containing value 'hello world', from the last hour
 */
const logs = logger.searchLogs('hello world', { time: '1h' });

License

logpile is released under the MIT License.

TODO

  • Improved search functionality
    • Search options for time (vercel's ms type eg. { time: '1wk' })
    • Search where timestamp between 2 values
    • Search items can be ranges (eg. { count > 2 && count < 4 })
  • Deno release

logpile's People

Contributors

skoshx avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.