pedestal

ccann 2020-06-17T18:14:57.230200Z

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

2020-06-17T18:25:06.230400Z

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

ccann 2020-06-17T18:41:39.230600Z

got it thanks

ccann 2020-06-17T19:10:37.230800Z

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))

ccann 2020-06-17T19:10:47.231Z

I just want to use the SLF4J logger

ccann 2020-06-17T19:11:08.231200Z

e.g.

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

2020-06-17T19:15:48.231400Z

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

2020-06-17T19:16:58.231800Z

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

2020-06-17T19:17:02.232Z

Sorry about that 😕

ccann 2020-06-17T19:40:52.232300Z

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

👍 1
jackson 2020-06-17T20:34:43.234500Z

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

2020-06-17T20:42:00.235700Z

@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

jackson 2020-06-17T20:43:42.237400Z

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.

jackson 2020-06-17T20:48:43.238100Z

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.

2020-06-17T20:50:17.238900Z

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

jackson 2020-06-17T20:54:26.242Z

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.

2020-06-17T21:05:30.244100Z

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

jackson 2020-06-17T21:23:17.244700Z

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