Should there be print statements in a library

I have built a library that is being used by a few people. They say that library has a few print statements which is wrong because a library should give freedom to users to use the library the way they want and forcing a few print statements is not good that way. Should there be print statements in a library by any ideology ?

5

Absolutely not, no. I don’t want your library spewing noise onto the console, into a log file or whatever else.

At least, that should be the default behaviour. If you really need it, have a way to set a “debug” flag which turns this kind of logging on. However, you shouldn’t need that for normal testing – that’s done by checking the return values in some kind of test harness, not by logging things.

1

Trả lời

Email của bạn sẽ không được hiển thị công khai. Các trường bắt buộc được đánh dấu *