Revision 2035039b

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

  
34
import logging
35

  
36
from synnefo import settings
37

  
38
from synnefo.util.dictconfig import dictConfig
39

  
40

  
41
class NullHandler(logging.Handler):
42
    def emit(self, record):
43
        pass
44

  
45
logging.NullHandler = NullHandler
46

  
47

  
48
def disable_unused_loggers():
49
    """Disable handlers that are not used by any logger"""
50

  
51
    logging = settings.LOGGING
52

  
53
    active_handlers = set()
54
    loggers = logging.get('loggers', {})
55
    for logger in loggers.values():
56
        active_handlers.update(logger.get('handlers', []))
57

  
58
    handlers = logging.get('handlers', {})
59
    for handler in handlers:
60
        if handler not in active_handlers:
61
            handlers[handler] = {'class': 'logging.NullHandler'}
62

  
63

  
64
disable_unused_loggers()
65
dictConfig(settings.LOGGING)
66

  
67

  
68
def getLogger(name):
69
    return logging.getLogger(name)
b/snf-cyclades-app/synnefo/admin/views.py
32 32
# or implied, of GRNET S.A.
33 33

  
34 34
from functools import wraps
35
from logging import getLogger
35 36

  
36 37
from django.conf import settings
37 38
from django.http import HttpResponse
......
40 41

  
41 42
from synnefo.db import models
42 43
from synnefo.logic import backend, users
43
from synnefo.util.log import getLogger
44 44

  
45 45

  
46 46
log = getLogger('synnefo.admin')
b/snf-cyclades-app/synnefo/api/flavors.py
31 31
# interpreted as representing official policies, either expressed
32 32
# or implied, of GRNET S.A.
33 33

  
34
from logging import getLogger
35

  
34 36
from django.conf.urls.defaults import patterns
35 37
from django.http import HttpResponse
36 38
from django.template.loader import render_to_string
......
38 40

  
39 41
from synnefo.api import util
40 42
from synnefo.db.models import Flavor
41
from synnefo.util.log import getLogger
42 43

  
43 44

  
44 45
log = getLogger('synnefo.api')
b/snf-cyclades-app/synnefo/api/images.py
31 31
# interpreted as representing official policies, either expressed
32 32
# or implied, of GRNET S.A.
33 33

  
34
from logging import getLogger
35

  
34 36
import dateutil.parser
35 37

  
36 38
from django.conf.urls.defaults import patterns
......
43 45
from synnefo.api.faults import BadRequest, ItemNotFound, ServiceUnavailable
44 46
from synnefo.api.util import api_method, isoformat, isoparse
45 47
from synnefo.plankton.backend import ImageBackend
46
from synnefo.util.log import getLogger
47 48

  
48 49

  
49 50
log = getLogger('synnefo.api')
b/snf-cyclades-app/synnefo/api/networks.py
31 31
# interpreted as representing official policies, either expressed
32 32
# or implied, of GRNET S.A.
33 33

  
34
from logging import getLogger
35

  
34 36
from django.conf.urls.defaults import patterns
35 37
from django.db.models import Q
36 38
from django.http import HttpResponse
......
43 45
from synnefo.api.faults import BadRequest, OverLimit, Unauthorized
44 46
from synnefo.db.models import Network
45 47
from synnefo.logic import backend
46
from synnefo.util.log import getLogger
47 48

  
48 49

  
49 50
log = getLogger('synnefo.api')
b/snf-cyclades-app/synnefo/api/servers.py
32 32
# or implied, of GRNET S.A.
33 33

  
34 34
from base64 import b64decode
35
from logging import getLogger
35 36

  
36 37
from django.conf import settings
37 38
from django.conf.urls.defaults import patterns
......
46 47
from synnefo.logic.backend import create_instance, delete_instance
47 48
from synnefo.logic.utils import get_rsapi_state
48 49
from synnefo.util.rapi import GanetiApiError
49
from synnefo.util.log import getLogger
50 50

  
51 51

  
52 52
log = getLogger('synnefo.api')
b/snf-cyclades-app/synnefo/api/util.py
32 32
# or implied, of GRNET S.A.
33 33

  
34 34
import datetime
35
import dateutil.parser
36 35

  
37 36
from base64 import b64encode
38 37
from datetime import timedelta, tzinfo
39 38
from functools import wraps
40 39
from hashlib import sha256
40
from logging import getLogger
41 41
from random import choice
42 42
from string import digits, lowercase, uppercase
43 43
from time import time
44 44
from traceback import format_exc
45 45
from wsgiref.handlers import format_date_time
46 46

  
47
import dateutil.parser
48

  
47 49
from Crypto.Cipher import AES
48 50

  
49 51
from django.conf import settings
......
57 59
from synnefo.db.models import (Flavor, VirtualMachine, VirtualMachineMetadata,
58 60
                               Network, NetworkInterface)
59 61
from synnefo.plankton.backend import ImageBackend
60
from synnefo.util.log import getLogger
61 62

  
62 63

  
63 64
log = getLogger('synnefo.api')
b/snf-cyclades-app/synnefo/api/versions.py
32 32
# or implied, of GRNET S.A.
33 33

  
34 34
from datetime import datetime
35
from logging import getLogger
35 36

  
36 37
from django.conf import settings
37 38
from django.http import HttpResponse
......
39 40
from django.utils import simplejson as json
40 41

  
41 42
from synnefo.api.util import api_method, isoformat
42
from synnefo.util.log import getLogger
43 43

  
44 44

  
45 45
log = getLogger('synnefo.api')
b/snf-cyclades-app/synnefo/logic/amqp_connection.py
29 29

  
30 30
import time
31 31
import socket
32

  
33
from logging import getLogger
34

  
32 35
from amqplib import client_0_8 as amqp
33 36
from django.conf import settings
34 37

  
35
from synnefo.util.log import getLogger
36

  
37 38

  
38 39
log = getLogger('synnefo.logic')
39 40

  
b/snf-cyclades-app/synnefo/logic/backend.py
33 33

  
34 34
import json
35 35

  
36
from logging import getLogger
37

  
36 38
from django.conf import settings
37 39
from django.db import transaction
38 40

  
......
40 42
                                NetworkLink)
41 43
from synnefo.logic import utils
42 44
from synnefo.util.rapi import GanetiRapiClient
43
from synnefo.util.log import getLogger
44 45

  
45 46

  
46 47
log = getLogger('synnefo.logic')
b/snf-cyclades-app/synnefo/plankton/util.py
34 34
import datetime
35 35

  
36 36
from functools import wraps
37
from logging import getLogger
37 38
from traceback import format_exc
38 39

  
39 40
from django.conf import settings
40 41
from django.http import (HttpResponse, HttpResponseBadRequest,
41
        HttpResponseServerError)
42
                         HttpResponseServerError)
42 43

  
43 44
from synnefo.plankton.backend import ImageBackend, BackendException
44
from synnefo.util.log import getLogger
45 45

  
46 46

  
47 47
log = getLogger('synnefo.plankton')
b/snf-cyclades-app/synnefo/plankton/views.py
33 33

  
34 34
import json
35 35

  
36
from logging import getLogger
36 37
from string import punctuation
37 38
from StringIO import StringIO
38 39
from urllib import unquote
......
41 42
from django.http import HttpResponse, HttpResponseNotFound
42 43

  
43 44
from synnefo.plankton.util import plankton_method
44
from synnefo.util.log import getLogger
45 45

  
46 46

  
47 47
FILTERS = ('name', 'container_format', 'disk_format', 'status', 'size_min',

Also available in: Unified diff