1 # Copyright (C) 2011-2012 W. Trevor King <wking@tremily.us>
3 # This file is part of pypid.
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
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.
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/>.
17 import logging as _logging
23 LOG = _logging.getLogger('pypid')
24 "Temperature-control logger"
26 #LOG.setLevel(_logging.WARN)
27 LOG.setLevel(_logging.DEBUG)
28 _formatter = _logging.Formatter(
29 '%(asctime)s - %(name)s - %(levelname)s - %(message)s')
31 _stream_handler = _logging.StreamHandler()
32 _stream_handler.setLevel(_logging.DEBUG)
33 _stream_handler.setFormatter(_formatter)
34 LOG.addHandler(_stream_handler)
36 _syslog_handler = None
39 def _set_handler(name='stream'):
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]
48 raise ValueError(name)
49 LOG.info('setup logging handler: %s' % name)