Code Monkey home page Code Monkey logo

dexter's People

Contributors

avnercohen avatar bcardiff avatar cyangle avatar jwoertink avatar matthewmcgarvey avatar paulcsmith avatar stephendolan avatar xosmond avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

dexter's Issues

Logging model records

If you have a model instance, and you want to log that, right now you might use pp. If you try and pass this to Lucky.logger.info, you'll find that nothing happens. No compile error, no output.

# This does nothing
Lucky.logger.info(UserQuery.first)

# This throws an error about undefined method to_json
Lucky.logger.info({record: UserQuery.first})

I'm thinking maybe the first way throws a compile-time error, and then we add a special method like inspect or whatever to models.

# error: If you're trying to log a model, be sure to call #inspect
Lucky.logger.info(UserQuery.first)

Lucky.logger.info(UserQuery.first.inspect)

Side related: luckyframework/lucky#950

Evaluate the future of this library

My understanding of history is that this library was made in a time where Crystal's Log class was not very robust and this library added functionality that was missing. (From what I've heard) The Log class is now better so we need to figure out what Dexter should look like going into the future and if there is even a place for it.

Should Dexter just be a library of formatters? Lucky has some formatters so should they be moved over or is it even worth it?

Allow reconfiguring log level on a per Fiber basis

Let's say in production you set the log level to info. Then a user reports a problem and you want to change the log level to debug just for you while you poke around.

I am not sure what the API looks like but I'd almost want to do something like

if params.get?(:enable_super_special_log_just_for_me)
  Log.current_fiber_level = :debug # Sets all logs to `:debug` *just* for the current Fiber
end

In a handler, before pipe, whatever. This would be super handy and I'd like to build something in for this at some point. So you can use Breeze in production but just with a special token set in the query param or a header

Add `Log#dexter.configure`

Right now the bind options in Log are not type-safe without some work. They are extremely flexible, but for Lucky's needs (and probably others?) we'd prefer type-safe config with some sensible defaults to keep things focused

# Configure all logs. Like bind *, etc.
Log.dexter.configure(:info, backend) 

# Can leave off the backend. Will configure Avram::Log and all children
Avram::Log.dexter.configure(:warn) 

# Can further customize child Logs
Avram::QueryLog.dexter.configure(:none) 
Avram::FailedQueryLog.dexter.configure(:info, SomeOtherBackend.new)

This I believe will cover the 90% use case with a simper API

Logger is formatter method is causing code to not compile when other libs use logger

The method formatter is causing other libraries to not compile:
https://github.com/luckyframework/dexter/blob/master/src/dexter/logger.cr#L53

# :nodoc:
  def formatter=(value) : Void
    {% raise "Use log_formatter= instead" %}
  end

So even when using ::Logger like:

    def initialize(@io : IO = STDOUT)
      @logger = ::Logger.new(@io)
      @logger.level = ::Logger::DEBUG
      @logger.progname = "crest"
      @logger.formatter = default_formatter
      @filters = [] of Array(String | Regex)
    end

    abstract def request(request : Crest::Request) : String
    abstract def response(response : Crest::Response) : String

    def default_formatter
      ::Logger::Formatter.new do |_, datetime, progname, message, io|
        io << progname
        io << " | " << datetime.to_s("%F %T")
        io << " " << message
      end
    end

It get's the following error:

  in lib/crest/src/crest/logger.cr:19: undefined method 'log_formatter=' for Logger (compile-time type is Logger+)

      @logger.log_formatter = Dexter::Formatters::JsonLogFormatter

Add log override helpers

For testing. Right now it is a pain. Would be easy with Habitat...hehe

Maybe we can make Habitat work for Crystal and get it in stdlib. We'll see though :)

Grouped Logging feature

When you log a bunch of asynchronous code, it gets logged out of order which leads to some confusing logs. To go along with luckyframework/lucky#950 (comment), one thing we could do is queue up everything that needs to be logged, then log the queue all at the same time.

This could also be along the same lines as #38 where using dexter becomes a queue center for logging and special formatting. Then you can use the standard Crystal Log for lower level control.

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.