jam icon indicating copy to clipboard operation
jam copied to clipboard

feat: ability to retrieve logs

Open theborakompanioni opened this issue 2 years ago • 1 comments

Closes #469.

First iteration of "feat: ability to retrieve logs #469". This PR uses features implemented in https://github.com/joinmarket-webui/jam-docker/pull/51 and must be tested in conjunction with it.

Features:

  • ability to retrieve logs
  • refresh log file contents
  • auto scroll to bottom on refresh
  • ~~colorize lines by log level~~ (reverted: uses too much memory)

Possible improvements for the next iteration:

  • auto refresh (aka "follow log output")
  • filter by log level
  • colorize lines by log level

Copying a phrase from the other PR:

As always, inputs are highly appreciated and especially welcomed on this PR, as it contains rather impactful changes. If you have any idea how to do things better or in a smarter way, please let me know!

Also, if you have any questions or are unsure about anything - don't hold back! Happy to answer and discuss any upcoming doubts/thoughts/ideas.

OLD How to test (outdated: see below)

  1. Rebuild the docker image for the secondary regtest container
  • Checkout branch serve-logs from jam-docker. See PR https://github.com/joinmarket-webui/jam-docker/pull/51 for more details.
  • Rebuild with
docker build --label "local" \
      --build-arg JAM_REPO_REF=master \
      --build-arg JM_SERVER_REPO_REF=master \
      --tag "joinmarket-webui/jam-standalone-logs-local" ./standalone
  1. Change the secondary docker image to use the newly built image
diff --git a/docker/regtest/dockerfile-deps/joinmarket/webui-standalone/Dockerfile b/docker/regtest/dockerfile-deps/joinmarket/webui-standalone/Dockerfile
index 84a1e68..f8a8ec4 100644
--- a/docker/regtest/dockerfile-deps/joinmarket/webui-standalone/Dockerfile
+++ b/docker/regtest/dockerfile-deps/joinmarket/webui-standalone/Dockerfile
@@ -1,4 +1,5 @@
-FROM ghcr.io/joinmarket-webui/jam-dev-standalone:master
+#FROM ghcr.io/joinmarket-webui/jam-dev-standalone:master
+FROM joinmarket-webui/jam-standalone-logs-local 
  1. Rebuild your local regtest setup, do not use npm run regtest:rebuild, but:
npm run regtest:clear && docker-compose \
        --env-file docker/regtest/.env.example \
        --file docker/regtest/docker-compose.yml build

(why? -> because --pull is not supported if you have a locally built image in your docker-compose setup)

  1. start the regtest env as normal, but instead of npm start, run:
npm run start:secondary

How to test (up-to-date)

  1. Rebuild your regtest env npm run regtest:rebuild
  2. Start Jam with npm run start:regtest:secondary

:camera_flash:

:camera_flash: reverted changes (just for reference; might re-implement in future iterations)

theborakompanioni avatar Aug 22 '22 21:08 theborakompanioni

Not sure about the primary/secondary naming, as mentioned, but maybe I'm misunderstanding things.

Introduced "backend types" native and jam-standalone in the setupProxy script. Everything can be controlled by environment variables now, with ports defaulting to jm's standard ports. Deliberately named a npm script "start:regtest:secondary" to indicate that this is intended for regtest use as the port is hardcoded to 29080 (the secondary regtest container). Feels like a major improvement - thanks again for the superb feedback! What do you think?

Also, with the docker image merged and built, one can use npm run regtest:rebuild with npm run start:regtest:secondary to try out the log feature! No more complicated steps as described in the original "How to test" description.

theborakompanioni avatar Aug 24 '22 12:08 theborakompanioni