pact-python icon indicating copy to clipboard operation
pact-python copied to clipboard

impossible to disable logging to file in `start_service` ?

Open mknaw opened this issue 2 years ago • 2 comments

please excuse my ignorance as I am new to the pact approach. perhaps there is something I am missing in the recommended workflow.

it seems like during normal local development, I may run my test suite without any interest in collecting pact-mock-service.log files

ultimately I suppose I could .gitignore these files in each consumer service... but it seems like it would be nice if I could provide something to pact constructor's log_dir or otherwise to opt out of the logging? appears to be hardcoded in the start_service command currently

mknaw avatar Jul 20 '23 17:07 mknaw

You are correct, it just isn't implemented as a feature.

It defaults to the current directory,

https://github.com/pact-foundation/pact-python/blob/00dcacd8ea49e8e90df3005d8883356286d061ae/pact/pact.py#L138

and then always applied to the underlying mock server cli call

https://github.com/pact-foundation/pact-python/blob/00dcacd8ea49e8e90df3005d8883356286d061ae/pact/pact.py#L203

contributions are welcome 👍🏾

YOU54F avatar Jul 25 '23 14:07 YOU54F

The default workflow in the majority of our repos, bar where they are shown for demonstration purposes is to .gitignore the log files and pact files which are generated each run, so they are not committed to source.

I would imagine if you did have the option, you may want to configure it from the outside, rather than having to update your code, to provide you logging by file, in the case of troubleshooting.

Does it log the same to stdout, as provided in the log file?

YOU54F avatar Jul 25 '23 14:07 YOU54F