#!/usr/bin/python # -*- mode: python; coding: utf-8 -*- # # Mandos server - give out binary blobs to connecting clients. # # This program is partly derived from an example program for an Avahi # service publisher, downloaded from # . This includes the # methods "add", "remove", "server_state_changed", # "entry_group_state_changed", "cleanup", and "activate" in the # "AvahiService" class, and some lines in "main". # # Everything else is # Copyright © 2008-2012 Teddy Hogeborn # Copyright © 2008-2012 Björn Påhlsson # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see # . # # Contact the authors at . # from __future__ import (division, absolute_import, print_function, # unicode_literals ) import errno import logging import logging.handlers logger = logging.getLogger() syslogger = (logging.handlers.SysLogHandler (facility = logging.handlers.SysLogHandler.LOG_DAEMON, address = str("/dev/log"))) def initlogger(debug, level=logging.WARNING): """init logger and add loglevel""" syslogger.setFormatter(logging.Formatter ('Wierd [%(process)d]: %(levelname)s:' ' %(message)s')) logger.addHandler(syslogger) if debug: console = logging.StreamHandler() console.setFormatter(logging.Formatter('%(asctime)s %(name)s' ' [%(process)d]:' ' %(levelname)s:' ' %(message)s')) logger.addHandler(console) logger.setLevel(level) # For convenience debug = 1 debug = 1 initlogger(debug, logging.DEBUG) logger.critical("No suitable Zeroconf service name found" " after %i retries, exiting.", )