beginners

Melody 2025-05-08T09:49:29.454389Z

What is a reliable way for me to get rid of these types of logs at the beginning of starting my application? It isn't important but it is kind of annoying.

PS G:\Programming\Clojure\Apr_2025\brainfloj\brainfloj> clojure -M:flow -m floj.cli
Unpacking to: C:\Users\me!\AppData\Local\Temp\jna--2013168224\neurosdk-x64.dll
Unpacking to: C:\Users\me!\AppData\Local\Temp\jna--2013168224\Unicorn.dll
Unpacking to: C:\Users\me!\AppData\Local\Temp\jna--2013168224\gForceSDKWrapper.dll
Unpacking to: C:\Users\me!\AppData\Local\Temp\jna--2013168224\gforce64.dll
Unpacking to: C:\Users\me!\AppData\Local\Temp\jna--2013168224\simpleble-c.dll
Unpacking to: C:\Users\me!\AppData\Local\Temp\jna--2013168224\MuseLib.dll
Unpacking to: C:\Users\me!\AppData\Local\Temp\jna--2013168224\BrainBitLib.dll
Unpacking to: C:\Users\me!\AppData\Local\Temp\jna--2013168224\GanglionLib.dll
Unpacking to: C:\Users\me!\AppData\Local\Temp\jna--2013168224\BrainFlowBluetooth.dll
Unpacking to: C:\Users\me!\AppData\Local\Temp\jna--2013168224\eego-SDK.dll
Unpacking to: C:\Users\me!\AppData\Local\Temp\jna--2013168224\BoardController.dll
I have logging set up and route the logging like this:
(defn configure-brainflow-logging!
  "Configure BrainFlow logging to write to our application logs directory"
  []
  (let [log-dir (str (System/getProperty "user.home") "/.lor/logs/device_logs")
        log-file (str log-dir "/brainflow.log")]
    (try
      (BoardShim/enable_dev_board_logger)
      (BoardShim/set_log_file log-file)
      (BoardShim/set_log_level LogLevels/LEVEL_INFO)
      (catch Exception e
        (println "Failed to configure BrainFlow logging:" (.getMessage e))))))

(defn redirect-system-output! []
  (let [log-file (str (System/getProperty "user.home") "/.lor/logs/app_logs/sys-out.log")
        log-stream (java.io.PrintStream. (java.io.FileOutputStream. log-file false))]
    (System/setOut log-stream)
    (System/setErr log-stream)))

(redirect-system-output!)
But while this stops a lot of other logs, it doesn't stop the jna ones

p-himik 2025-05-08T10:02:06.460579Z

Interesting, I can't find Unpacking to anywhere in the JNA sources. Are you sure it comes from JNA itself?

Melody 2025-05-08T10:07:22.079409Z

It could possibly be from the brainflow package itself. https://github.com/brainflow-dev/brainflow/blob/master/java_package/brainflow/pom.xml

Melody 2025-05-08T10:09:02.044659Z

Ah following your strategy, I looked up "Unpacking to" in the brainflow api and it led to this https://github.com/brainflow-dev/brainflow/blob/580f69354abbc0afc4612c4dbd1ea42538c0f84a/java_package/brainflow/src/main/java/brainflow/JarHelper.java#L27 at line 27

p-himik 2025-05-08T10:46:45.544009Z

That's unfortunate. I would definitely create an issue on their GitHub asking to implement a more proper logging mechanism. System/setErr should have worked, but maybe those lines are generated before the namespace where you call redirect-system-output! is loaded.

👍 1
Melody 2025-05-08T11:50:58.821609Z

Thanks, I will and there is also a slack for just brainflow I might be able to reach out to as well. I will look into it.

👍 1
valerauko 2025-05-08T03:39:37.921499Z

Is there some smart way for a conversion like below? Anything shorter/prettier/faster than nested reduce-kv

{:a {:x 1 :y 2} :b {:y 3 :z 4}} -> {:x {:a 1} :y {:a 2 :b 3} :z {:b 4}}

2025-05-08T03:52:45.786339Z

this isn't enough information to know the best way to perform that transformation

2025-05-08T03:56:36.753329Z

where does :y {:a 1} come from?

valerauko 2025-05-08T04:03:34.286229Z

That one was a silly typo. Given a nested map, "flip it inside out" so that the inner maps' keys are in the outer map and vice versa

👍 1
p-himik 2025-05-08T04:38:52.619609Z

> Anything shorter/prettier/faster Maybe a library, could be Specter. But can't say for sure. Or https://stackoverflow.com/a/7290026/564509:

(let [input {:a {:x 1 :y 2} :b {:y 3 :z 4}}
      expected {:x {:a 1} :y {:a 2 :b 3} :z {:b 4}}]
  (= expected
     (apply merge-with merge
            (for [[ok ov] input
                  [ik iv] ov]
              {ik {ok iv}}))))