Revision 888355d1

/dev/null
1
[loggers]
2
keys=root,synnefo.dispatcher
3

  
4
[handlers]
5
keys=consoleHandler
6

  
7
[formatters]
8
keys=fullFormatter
9

  
10
[logger_root]
11
level=DEBUG
12
handlers=consoleHandler
13

  
14
[logger_synnefo.dispatcher]
15
level=DEBUG
16
handlers=consoleHandler
17
qualname=synnefo.dispatcher
18
propagate=0
19

  
20
[handler_consoleHandler]
21
class=StreamHandler
22
level=DEBUG
23
formatter=fullFormatter
24
args=(sys.stdout,)
25

  
26
[formatter_fullFormatter]
27
format=%(asctime)s - %(name)s[%(process)d] - %(levelname)s - %(message)s
b/logic/dispatcher.py
44 44
path = os.path.normpath(os.path.join(os.getcwd(), '..'))
45 45
sys.path.append(path)
46 46
import synnefo.settings as settings
47
from synnefo.logic import log
47 48

  
48 49
setup_environ(settings)
49 50

  
50 51
from amqplib import client_0_8 as amqp
51 52
from signal import signal, SIGINT, SIGTERM
52 53

  
53
import logging
54
import logging.config
55 54
import time
56 55
import socket
57 56
from daemon import pidfile, daemon
58
import lockfile.pidlockfile
59 57

  
60 58
from synnefo.logic import callbacks
61 59

  
62

  
63 60
class Dispatcher:
64 61

  
65 62
    logger = None
......
68 65
    clienttags = []
69 66

  
70 67
    def __init__(self, debug = False):
68
        
71 69
        # Initialize logger
72
        logging.config.fileConfig("/Volumes/Files/Developer/grnet/synnefo/logging.conf")
73
        self.logger = logging.getLogger("synnefo.dispatcher")
70
        self.logger = log.get_logger('synnefo.dispatcher')
74 71

  
75 72
        self.debug = debug
76 73
        self._init()
......
231 228
    global children, logger
232 229
    (opts, args) = parse_arguments(sys.argv[1:])
233 230

  
234
    # Initialize logger
235
    logging.config.fileConfig("logging.conf")
236
    logger = logging.getLogger("synnefo.dispatcher")
231
    logger = log.get_logger("synnefo.dispatcher")
237 232

  
238 233
    # Special case for the clean up queues action
239 234
    if opts.cleanup_queues:
......
292 287
        pidf.release()
293 288

  
294 289
if __name__ == "__main__":
295
    logging.basicConfig(level=logging.DEBUG)
296 290
    sys.exit(main())
297 291

  
298 292
# vim: set sta sts=4 shiftwidth=4 sw=4 et ai :
b/logic/log.py
1
# Copyright 2011 GRNET S.A. All rights reserved.
2
#
3
# Redistribution and use in source and binary forms, with or without
4
# modification, are permitted provided that the following conditions
5
# are met:
6
#
7
#   1. Redistributions of source code must retain the above copyright
8
#      notice, this list of conditions and the following disclaimer.
9
#
10
#  2. Redistributions in binary form must reproduce the above copyright
11
#     notice, this list of conditions and the following disclaimer in the
12
#     documentation and/or other materials provided with the distribution.
13
#
14
# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
15
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17
# ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
18
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24
# SUCH DAMAGE.
25
#
26
# The views and conclusions contained in the software and documentation are
27
# those of the authors and should not be interpreted as representing official
28
# policies, either expressed or implied, of GRNET S.A.
29

  
30

  
31
""" Logging configuration defaults
32

  
33
    Uses Python's logging framework and applies Synnefo conventions to it.
34
"""
35

  
36
import logging
37
import logging.config
38
import os
39

  
40
import synnefo.logic
41

  
42
if os.path.exists("/etc/synnefo/logging.conf"):
43
    logconf = "/etc/synnefo/logging.conf"
44
elif os.path.exists(os.path.join(os.getcwd(), 'logging.conf')):
45
    logconf = os.path.join(os.getcwd(), 'logging.conf')
46
else:
47
    logconf = os.path.join(synnefo.logic.__path__[0], 'logging.conf')
48

  
49
logging.config.fileConfig(logconf)
50

  
51
def get_logger(logger):
52
    return logging.getLogger(logger)
b/logic/logging.conf
1
[loggers]
2
keys=root,synnefo.dispatcher
3

  
4
[handlers]
5
keys=consoleHandler
6

  
7
[formatters]
8
keys=fullFormatter
9

  
10
[logger_root]
11
level=DEBUG
12
handlers=consoleHandler
13

  
14
[logger_synnefo.dispatcher]
15
level=DEBUG
16
handlers=consoleHandler
17
qualname=synnefo.dispatcher
18
propagate=0
19

  
20
[handler_consoleHandler]
21
class=StreamHandler
22
level=DEBUG
23
formatter=fullFormatter
24
args=(sys.stdout,)
25

  
26
[formatter_fullFormatter]
27
format=%(asctime)s - %(name)s[%(process)d] - %(levelname)s - %(message)s

Also available in: Unified diff