pine-vm / pine

Cross-platform runtime environment for the Elm programming language.
https://pine-vm.org
MIT License
218 stars 18 forks source link

Debug.log in backend code #3

Open PgLoLo opened 4 years ago

PgLoLo commented 4 years ago

Is it possible to see the Debug.log output in the backend side? In frontend Debug.log works as usual, but in the backend side I couldn't find where I can see the output.

Viir commented 4 years ago

There is no implementation so far to collect or forward what goes into Debug.log in the backend. Currently, the backend uses a javascript engine to run the Elm code. As long as we use the javascript engine way, I think it should be possible to add a javascript method that collects the logged values and then get them out after each event/msg. Also, the javascript engine could already have an API to forward from console.log.

Currently, there is this code to ensure log statements in the javascript don't crash the app: https://github.com/elm-fullstack/elm-fullstack/blob/c29fbe5b433aff7d5cd133e7f8e529133a5394ba/implement/PersistentProcess/PersistentProcess.Common/Process.cs#L393-L409

I also found a related example of logging implementations: https://discourse.elm-lang.org/t/i-successfully-ran-an-elm-worker-from-python/5451/2?u=viir

Viir commented 3 years ago

Now that more of the infrastructure is in place, I don't expect any significant challenge for collecting the log entries from the backend app. An open question remaining is how should the interface to read the log entries look like. At the moment, I guess you'd present the log entries as part of the function application they resulted from. In an inspection view, you might have a list of function applications to present the state thread. When expanding the representation of a history step, the log entries would appear under that history step.