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