amperity / dialog

Simple just-enough logging library for Clojure
MIT License
39 stars 2 forks source link

Sentry appender #12

Closed ieugen closed 2 years ago

ieugen commented 2 years ago

I would like to use this library but we use Sentry and we would need a sentry appender. Does this library support this kind of extension?

I did not see anything in the docs. The outputs seem to be a fixed list. Nothing about adding your own: db, sentry, etc.

greglook commented 2 years ago

Your interpretation is correct - dialog is currently closed to extension, but I think it'd be possible to change that. Right now the output formatters and writers are a fixed set of keywords, but we could change that to interpret a symbol as a var to be resolved at runtime. 🤔

ieugen commented 2 years ago

Would it support multiple appenders - like the current loggers do ? We have Sentry in addition to console logging (running in containers).

greglook commented 2 years ago

It already does; in the example included in the repository, the :main profile would write to both the :stdout and :loggly outputs: https://github.com/amperity/dialog/blob/bd2cee1ef1e0c8b10d16802b99c897a9515c3ce7/dev/dialog.edn#L49-L55

ieugen commented 2 years ago

we could change that to interpret a symbol as a var to be resolved at runtime.

Or the symbol could be anything and the value should be a map with a specific key that is interpreted as a var to resolve at runtime ?! Don't know if it makes any difference but my spidey sense tells me to keep the key - a simple key.

greglook commented 2 years ago

I'm picturing a configuration like this for a custom output:

:outputs
{:foo {:type com.acme.logging/sentry
       :format :json
       :api-key #env SENTRY_API_KEY
        ,,,}}

Since the :type key is a symbol instead of one of the built-in keywords, it'd get resolved to a var at runtime and called with the output map, which could contain any additional info necessary to configure it.

greglook commented 2 years ago

With the ability for users to provide custom outputs with a qualified symbol, I think this is satisfied. Sentry is specific enough that it wouldn't be included in the base library, though I could see a separate dialog-sentry project providing a compatible output writer.