off-topic

https://github.com/clojurians/community-development/blob/master/Code-of-Conduct.md Clojurians Slack Community Code of Conduct. Searchable message archives are at https://clojurians-log.clojureverse.org/
slipset 2021-03-27T07:45:17.318200Z

I guess one of the “selling points” of eg wildfly is that devs can focus on the code whereas your wildfly-admin can tune the runtime performance of it, and do so uniformly across a bunch of deployments. A related example. I’m currently throwing out our xml-config-based logging and replacing it with timbre. As a dev this is wonderful, as my logging config is for the first time understandable. But from an ops perspective, with the xml based stuff, they could tune the logging at their will, now they’re at the mercy of what ever home grown env-variable passing scheme I come up with.

seancorfield 2021-03-27T07:48:20.318800Z

@slipset We switched away from Timbre for exactly that reason (and went to log4j2).

seancorfield 2021-03-27T07:49:22.319900Z

We tried tools.logging first, switched to Timbre for the flexibility, then decided it wasn’t worth the mess of non-standard code and the dependencies that Timbre dragged in, and went back to tools.logging 🙂

Dimitar Uzunov 2021-03-27T08:09:22.320900Z

As far as I've seen Java application servers are not liked by unix admins, although people who have received corporate training seem to like them. So wildfly/websphere/etc admin seems to a category that exists.

Dimitar Uzunov 2021-03-27T08:11:43.321100Z

I wouldn't bet on a corporate admin in a bank for example being willing to spent time tweaking an application server - more likely they will require it from the vendor/consultants

slipset 2021-03-27T08:47:49.322300Z

I’m not saying that ops will do not love it. I’m just saying it’s a feature/selling point.

👍 1
Dimitar Uzunov 2021-03-27T12:23:58.322800Z

You are right and it probably was probably how things were approached around 2000 when these conventions were first set (before the mass adoption of virtualisation and containerisation, Ruby on rails and so on) .

phronmophobic 2021-03-27T22:02:20.325700Z

Does anyone have a recommendation for inspecting stacktraces? The main info I'm interested in is determining the filename, line no, and column for a given stack trace element. I found https://github.com/mmcgrana/clj-stacktrace, but wanted to check what other options might be a good fit.

seancorfield 2021-03-27T22:07:15.326200Z

@smith.adriane Throwable->map in clojure.core?

phronmophobic 2021-03-28T19:21:24.332200Z

For completeness, here's what I came up with to find the source based on the info in a StackTraceElement, https://github.com/phronmophobic/reveal-exception/blob/main/src/com/phronemophobic/reveal_plugin/reveal_exception.clj#L83

seancorfield 2021-03-27T22:07:59.327Z

(with demunge calls, I guess, to turn the class/function name back into Clojure “source”?)

phronmophobic 2021-03-27T22:08:56.327900Z

yea. afaict, it seems the raw output needs some coercing which is why I was looking at clj-stacktrace

phronmophobic 2021-03-27T22:10:38.328Z

My plan is to build a reveal plugin that makes it easier to inspect exceptions and then open the corresponding file in my editor

seancorfield 2021-03-27T22:14:50.328200Z

dev=> (->> (ex-info "Boom!" {}) (Throwable->map) :trace (map (fn [[cl meth file line]] [(demunge (str cl)) (keyword meth) file line])) (remove (comp #{:invokeStatic} second)))

seancorfield 2021-03-27T22:15:09.328400Z

Not sure whether invoke or invokeStatic is the thing to filter out.

seancorfield 2021-03-27T22:15:35.328600Z

And maybe some layers of clojure.core etc?

phronmophobic 2021-03-27T22:20:14.328800Z

clj-stacktrace will first try to determine if a stacktrace element corresponds to clojure code and then use a different mechanism to figure out the filename and line number

phronmophobic 2021-03-27T22:20:25.329Z

I looked at the source code for cider and it seems like it's doing the same thing

seancorfield 2021-03-27T22:22:40.329200Z

Ah, cool.

phronmophobic 2021-03-27T22:37:07.329400Z

I might also be able to get away with a modified version of clojure.repl/stacktrace-element-str

(defn stack-element-str
  "Returns a (possibly unmunged) string representation of a StackTraceElement"
  {:added "1.3"}
  [^StackTraceElement el]
  (let [file (.getFileName el)
        clojure-fn? (and file (or (.endsWith file ".clj")
                                  (.endsWith file ".cljc")
                                  (= file "NO_SOURCE_FILE")))]
    (str (if clojure-fn?
           (demunge (.getClassName el))
           (str (.getClassName el) "." (.getMethodName el)))
         " (" (.getFileName el) ":" (.getLineNumber el) ")")))

2021-03-27T22:48:44.329600Z

The stack trace doesn't contain the entire path name to the source file, does it? I thought it only contained the last part of the path, e.g. core.clj Also no column numbers?

phronmophobic 2021-03-27T22:49:58.329800Z

Yes, that's correct. Line numbers are good enough for my use case.

phronmophobic 2021-03-27T22:51:00.330Z

using the above, I can also get the qualified symbol for the function calls which means I can usually find the source

walterl 2021-03-27T23:06:52.330400Z

I wrote a neovim plugin to populate the (nvim) quickfix list with the locations from a stack trace. It queries a connected nREPL for the ns-path of an ns

walterl 2021-03-27T23:07:42.330600Z

It's not published anywhere (still early stages), but I'll share if you're interested

walterl 2021-03-27T23:08:19.330800Z

It parses stack traces from text, though

phronmophobic 2021-03-27T23:34:52.331Z

Using a modified version of clojure.repl/stack-element-str along with modified version of clojure.repl/source-fn seems to work for me.