Closed khoin closed 6 years ago
Thanks, Koi. I think it's okay to send all of the log messages to the browser. It usually won't be a problem because under normal usage the model runs much more slowly than in the test cases, and if it continues to be a problem, we can just set it up to write log messages less often.
So I think what we can do is this line, we can add cmd.OutOrStdout
to the list of writers that are being logged to, and remove os.Stdout so that we're not logging the messages to the console twice.
Also, the the eval
subdirectory is failing to compile, which I think you can fix by adding an empty cmd
argument to the Run()
functions in that directory.
Hi Chris,
I've routed the output directly to the Cobra.Command writer now. I've also fixed for the tests in eval/. The tests pass with Travis CI but fails on my laptop Windows computer for some reasons. I don't think I'll be able to track it down.
I thinks this should be good now. I'm not sure if this catches all outputs from the program, but I don't think I can track down all the output messages in time either.
Thanks, Koi. This looks good. Just one thing: you need to run dep ensure --update github.com/ctessum/gobra
and then commit the results to make sure the most recent version of gobra is getting used. If you don't have the correct versions of the dependencies installed (by using dep ensure
) on your laptop that could also be what's causing the tests to fail for you.
updated gopkg.
Thanks!
Hi Chris,
This is the way I'd route messages from InMap to Gobra (web interface).
The browser isn't happy with it being bombarded with thousands of messages, so I couldn't add
CobraCommand.OutOrStdout()
tomw
MultiWriter (in line 131 of inmaputil/inmap.go).However, I routed some of the messages, and it was okay with that. Here's a screenshot showing the
percentage change since last convergence check
and theadding grid cells...
but not theiteration xxx walltime=[...]
.Hope this makes sense. I figured you would know better about which messages you'd prefer to send to the browser as well, so this PR is merely a draft.
I am not exactly sure where to put the documentation for this because it's scattered everywhere, but here are different ways to print a message to the browser:
*cobra.Command
print methods when InMap is running with Gobra. E.g., Println, Printf, etc.*cobra.Command.OutOrStdout()
when InMap is running with Gobra (this line sets Cobra output to Gobra). E.g.cmd.OutOrStdout().Write([]byte("Test"))
gobra.Server
. This struct implementsio.Writer
whereWrite
ing to it will output on the browser. This struct gets pointed to byOutOrStdout()
above when run with InMap/Cobra.Let me know if anything is unclear.