Is there a way to change the way the logged map is formatted with io.pedestal.log
?
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
got it thanks
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))
I just want to use the SLF4J logger
e.g.
(defmacro info [& keyvals]
(let [log-map (-> (apply array-map keyvals)
(assoc ::log/formatter formatter))]
`(log/log ~log-map :info)))
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
You can either create an override-logger which essentially does (LoggerFactory/getLogger logger-name)
or drop back to Pedestal version 0.5.7
Sorry about that 😕
ah no worries, thanks so much for the help. dropping to 0.5.7 did what I wanted
It is possible to have a route that differs by scheme only? http://**/path/
and ws://*/path/
for example.*
@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
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.
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.
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
Check out the Jetty Websockets sample: https://github.com/pedestal/pedestal/blob/master/samples/jetty-web-sockets/src/jetty_web_sockets/service.clj#L87
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.
It’s not possible to share paths between ws
and http(s)
schemes. Separate servlets are added per ws
path.
Hmm ok. I’ll keep looking for a workaround.