3
# Copyright 2013 Facundo Batista
5
# This program is free software: you can redistribute it and/or modify it
6
# under the terms of the GNU General Public License version 3, as published
7
# by the Free Software Foundation.
9
# This program is distributed in the hope that it will be useful, but
10
# WITHOUT ANY WARRANTY; without even the implied warranties of
11
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
12
# PURPOSE. See the GNU General Public License for more details.
14
# You should have received a copy of the GNU General Public License along
15
# with this program. If not, see <http://www.gnu.org/licenses/>.
17
# For further info, check https://launchpad.net/encuentro
19
"""Set up the logs."""
30
_rootlogger = logging.getLogger("")
31
_rootlogger.setLevel(logging.DEBUG)
32
formatter = logging.Formatter('%(asctime)s %(levelname)7s '
33
'%(name)s: %(message)s')
36
_handler = logging.StreamHandler()
37
level = logging.WARNING if shy else logging.DEBUG
38
_handler.setLevel(level)
39
_rootlogger.addHandler(_handler)
40
_handler.setFormatter(formatter)
43
if not os.path.exists(LOG_DIR):
45
fname = time.strftime(os.path.join(LOG_DIR, "encserver-%Y%m.log"))
46
_handler = logging.FileHandler(fname)
47
_handler.setLevel(logging.DEBUG)
48
_rootlogger.addHandler(_handler)
49
_handler.setFormatter(formatter)