Yes, that will work (although the exception should be limited to just catching ImportError).
Or, just use old-style "syslog" logging. It will work fine, but you'll get a mix of new- and old-style logging formats. -tk On Sat, Mar 14, 2020 at 11:17 AM Vince Skahan <[email protected]> wrote: > Tom - I updated the driver I'm fiddling with per your wiki, and noticed > that there's no backward compatibility example for the "In main programs" > example at the top of the wiki page. Does this look right as a potential > addition to the wiki ? > > Tests out ok on python3 / weewx4 FWIW.... > > if __name__ == "__main__": > usage = """%prog [options] [--help]""" > > def main(): > try: > import logging > import weeutil.logger > log = logging.getLogger(__name__) > weeutil.logger.setup('mydrivername', {} ) > except: > import syslog > syslog.openlog('mydrivername', syslog.LOG_PID | > syslog.LOG_CONS) > > > > > > -- > You received this message because you are subscribed to the Google Groups > "weewx-development" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/weewx-development/58ba0277-d263-4e88-aa2f-0292482537a6%40googlegroups.com > <https://groups.google.com/d/msgid/weewx-development/58ba0277-d263-4e88-aa2f-0292482537a6%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "weewx-development" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-development/CAPq0zEB4V%2Bh1LR7Ktko%3DoF6b3cz3br5udhy6mgx3sb7EajKePA%40mail.gmail.com.
