Skip to content
This repository has been archived by the owner on Aug 5, 2020. It is now read-only.

Commit

Permalink
avoid "No handler found" warnings in an authoritative way
Browse files Browse the repository at this point in the history
  • Loading branch information
youfou committed Jun 16, 2017
1 parent f3006f8 commit 9906b0d
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions wxpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ def auto_accept_friends(msg):
"""

import sys
import logging
import sys

from .api.bot import Bot
from .api.chats import Chat, Chats, Friend, Group, Groups, MP, Member, User
Expand All @@ -75,4 +75,12 @@ def auto_accept_friends(msg):
version_details = 'wxpy {ver} from {path} (python {pv.major}.{pv.minor}.{pv.micro})'.format(
ver=__version__, path=__path__[0], pv=sys.version_info)

logging.basicConfig()
try:
# Python 2.7+
from logging import NullHandler
except ImportError:
class NullHandler(logging.Handler):
def emit(self, record):
pass

logging.getLogger(__name__).addHandler(NullHandler())

0 comments on commit 9906b0d

Please sign in to comment.