Best practices for Serial printing in library

I am writing an IoT library that will be publicly available. It regularly prints various things to the Serial monitor. I was wondering it's not a good idea to have this, or if its common to have it work this way.

What kind of conflicts could this cause? I know there are plenty of other digital IO pins usually available on most devices other than the tx/rx pins. I would rather not change it too much but wanted to makes sure that this was not potentially a big problem.

Thanks very much in advance..

You can add conditional logging, e.g. by #ifdef DEBUG, and leave it to the user otherwise.

oraz:
I am writing an IoT library t.......regularly prints various things to the Serial monitor. I was wondering it's a good idea.....I would rather not change it too much but wanted to makes sure that this was not potentially a big problem.

It isn't, and the best way to do that is by not doing it. Serial printing has nothing to do with IoT, and is surely something best left to the user. As things are, the only way anybody prints to the serial monitor is by the built in interface that shares pins 0 Rx and 1 Tx. Anything you do that changes that will make the library useless.

Hi Oraz,

What types of information are you displaying? Is this intended to support troubleshooting or are you providing some useful information?

If you are writing a library, you probably are writing a set of utility functions. In that case, you may prefer to provide helper functions that can return a code or string that a user can print if they choose.

Pat.