Adding custom prints/Info logs in code

Hi,

In order to better understand the Docker code flow, I’d like to add some print statements which I can see on output later when I issue commands from cli. I first tried the usual fmt.Println() but it didn’t work. I followed the docker development container procedure as documented under moby’s contributing guidelines. Is there a common or standard way of adding prints/info logs?

Are you using the modified cli? moby/moby pulls in an old cli.

fmt.Println should be fine.

Brian Goff

Hi Brian,

Just confirming that fmt.Println() works fine. The previous post was due to an error on my side where I added the prints at the wrong place in the code based on my initial understanding of the module and therefore didn’t see the traces I added. I’ve corrected it now and can see the prints. Thanks for your quick response, though I still have one question
I added the print statement in moby/api/server/router/swarm/cluster_routes.go and followed the moby dev container procedure to rebuild the docker binary and view my added traces. Will the process remain the same if I were to add some prints in any of the code files in the swarmkit repository instead of the moby/moby repository? (Assuming the vendor.conf of moby/moby is updated correctly to point to this modified swarmkit git repo)

Regards,
Niket