Fork me on GitHub
#pedestal
<
2020-06-17
>
ccann18:06:57

Is there a way to change the way the logged map is formatted with io.pedestal.log?

ddeaguiar18:06:06

The formatter can be specified through the key io.pedestal.log/formatter which should be > A single-arg function that when given a map, returns a String for logging, defaults to pr-str You can always create your own logging macros based on the io.pedestal.log/log fn if you desire more control over logging but that won’t change the format of messages logged by Pedestal’s internals

ccann18:06:39

got it thanks

ccann19:06:37

I’m probably making a stupid mistake, buy my macros don’t work because io.pedestal.log/log throws an NPE when it calls (and override-logger (override-logger logger-name))

ccann19:06:47

I just want to use the SLF4J logger

ccann19:06:08

e.g.

(defmacro info [& keyvals]
  (let [log-map (-> (apply array-map keyvals)
                    (assoc ::log/formatter formatter))]
    `(log/log ~log-map :info)))

ddeaguiar19:06:48

ah crud, yes. There’s an issue open for this https://github.com/pedestal/pedestal/issues/662. The fix is already on master but a new release has not been cut

ddeaguiar19:06:58

You can either create an override-logger which essentially does (LoggerFactory/getLogger logger-name) or drop back to Pedestal version 0.5.7

ddeaguiar19:06:02

Sorry about that 😕

ccann19:06:52

ah no worries, thanks so much for the help. dropping to 0.5.7 did what I wanted

👍 3
jackson20:06:43

It is possible to have a route that differs by scheme only? http://**/path/ and ws://*/path/ for example.*

ddeaguiar20:06:00

@jackson.reynolds generally yes, see http://pedestal.io/reference/routing-quick-reference. Although for your specific example, the ws scheme pertains to WebSockets and that’s resolved at a higher level by the hosting container

jackson20:06:42

I tried specifying the scheme specifically for http but as soon as I add the ws path back in I’m getting a 405 for the http endpoint.

jackson20:06:43

Just for clarity, I can have either the http or the ws endpoint working, but only one or the other and I can’t seem to get both working at the same time. Interestingly, I had this working when I was using POST for the http endpoint, but switching to GET seems to have caused the issue.

ddeaguiar20:06:17

If you’re using WebSockets, use the facilities provided by the container you are deploying to. For example, if using Jetty, refer to https://github.com/pedestal/pedestal/blob/master/jetty/src/io/pedestal/http/jetty/websockets.clj

jackson20:06:26

Yes, that’s what I have working for websockets. So when I configure the http path as a POST it works, when I configure it as a GET it doesn’t. There’s also a trailing ‘/’ at the end of the url, but I’m not sure how that could affect things.

ddeaguiar21:06:30

It’s not possible to share paths between ws and http(s) schemes. Separate servlets are added per ws path.

jackson21:06:17

Hmm ok. I’ll keep looking for a workaround.