Ran update-copyright.py.
[pypid.git] / pypid / __init__.py
1 # Copyright (C) 2011-2012 W. Trevor King <wking@tremily.us>
2 #
3 # This file is part of pypid.
4 #
5 # pypid is free software: you can redistribute it and/or modify it under the
6 # terms of the GNU General Public License as published by the Free Software
7 # Foundation, either version 3 of the License, or (at your option) any later
8 # version.
9 #
10 # pypid is distributed in the hope that it will be useful, but WITHOUT ANY
11 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License along with
15 # pypid.  If not, see <http://www.gnu.org/licenses/>.
16
17 import logging as _logging
18
19
20 __version__ = '0.3'
21
22
23 LOG = _logging.getLogger('pypid')
24 "Temperature-control logger"
25
26 #LOG.setLevel(_logging.WARN)
27 LOG.setLevel(_logging.DEBUG)
28 _formatter = _logging.Formatter(
29     '%(asctime)s - %(name)s - %(levelname)s - %(message)s')
30
31 _stream_handler = _logging.StreamHandler()
32 _stream_handler.setLevel(_logging.DEBUG)
33 _stream_handler.setFormatter(_formatter)
34 LOG.addHandler(_stream_handler)
35
36 _syslog_handler = None
37
38
39 def _set_handler(name='stream'):
40     if name == 'syslog':
41         if not _syslog_handler:
42             _syslog_handler = _logging_handlers.SysLogHandler()
43             _syslog_handler.setLevel(_logging.DEBUG)
44         LOG.handlers = [_syslog_handler]
45     elif name == 'stream':
46         LOG.handlers = [_stream_handler]
47     else:
48         raise ValueError(name)
49     LOG.info('setup logging handler: %s' % name)