Giter VIP home page Giter VIP logo

logger's Introduction

Simple Logger

Running

  • Clone this repo
  • serve directly with php-cli by running:

    php -S localhost:7111

Assumptions

  • Laravel is not being used and the code is meant to be generic. This is because the Log facade in Laravel does most of what is being done here. This also means that:
    • there is no config function so I needed to use getenv/putenv
    • No log rotate thought was put into this and only direct file append (monolog takes care of this)
    • not done in a Helper structure since it is outside of Laravel but used a pseudo-mvc structure out of habit

Adding log targets

Change the way that the config/env works and set it as a 2-dimentional array. Each level would be an index and an array of handlers would be used for each. This would allow a level to both write to file and trigger an API notification.

Minimum log levels per target

Add another array containing the minimum levels for each type of handler and create a method to set these receiving the handler and the minimum level.

How to make this more extensible

Extrapolate this to a company-wide or public package so all projects could use a single source of truth

Improvements

  • hook different Log managers like Grafana, DataDog, Cloudwatch, etc... using handlers
  • add handlers that would trigger notification APIs based on the specific log rules like "Errors with the text database timeout". These notifications would use services like Twilio, MailGun, Slack, etc... for emergency notifications that would bypass minimum levels.
  • check to make sure that the env config is in place for the minimum log level

logger's People

Contributors

yurisalame avatar

Watchers

Yuri Salame 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.