libsmb offers the possibility to set up debugging using smbc_setOptionDebugToStderr() but only after a context has been established with smbc_new_context().
However, smbc_new_context() can still emit log messages, which, combined with "log level" setting in smb.conf might lead to stdout output which cannot be easily suppressed.
It would be better to offet some way to set up logging target prior to creating a new context -- via some "global" call like smbc_global_debug_to_stderr() or even some environment variable.
btw see https://fedorahosted.org/sssd/ticket/2544 for a real-world consequence.
I should also add that I'm fine with contributing a fix if there's a consensus if and how to fix the problem.