Skip to content

Commit 5c5a455

Browse files
Grégoire Deveauxjelly
authored andcommitted
Mutualize commands logger configs
1 parent 4283ed7 commit 5c5a455

File tree

16 files changed

+45
-106
lines changed

16 files changed

+45
-106
lines changed

devel/management/commands/archweb_inotify.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,14 @@
22
import multiprocessing
33
import os
44
import pyinotify
5-
import sys
65
import threading
76
import time
87

98
from django.db.utils import OperationalError
109

1110

12-
logging.basicConfig(
13-
level=logging.WARNING,
14-
format='%(asctime)s -> %(levelname)s: %(message)s',
15-
datefmt='%Y-%m-%d %H:%M:%S',
16-
stream=sys.stderr)
17-
logger = logging.getLogger()
11+
logger = logging.getLogger("command")
12+
logger.setLevel(logging.WARNING)
1813

1914

2015
class Database(object):

devel/management/commands/generate_keyring.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,10 @@
1111

1212
import logging
1313
import subprocess
14-
import sys
1514

1615
from devel.models import MasterKey, UserProfile
1716

18-
logging.basicConfig(
19-
level=logging.INFO,
20-
format='%(asctime)s -> %(levelname)s: %(message)s',
21-
datefmt='%Y-%m-%d %H:%M:%S',
22-
stream=sys.stderr)
23-
logger = logging.getLogger()
17+
logger = logging.getLogger("command")
2418

2519

2620
class Command(BaseCommand):

devel/management/commands/pgp_import.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
import logging
1313
from pytz import utc
1414
import subprocess
15-
import sys
1615

1716
from django.core.management.base import BaseCommand, CommandError
1817
from django.db import transaction
@@ -21,12 +20,7 @@
2120
from devel.utils import UserFinder
2221

2322

24-
logging.basicConfig(
25-
level=logging.INFO,
26-
format='%(asctime)s -> %(levelname)s: %(message)s',
27-
datefmt='%Y-%m-%d %H:%M:%S',
28-
stream=sys.stderr)
29-
logger = logging.getLogger()
23+
logger = logging.getLogger("command")
3024

3125

3226
class Command(BaseCommand):

devel/management/commands/read_rebuilderd_status.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
import logging
1212
import re
13-
import sys
1413

1514
from collections import defaultdict
1615

@@ -28,12 +27,7 @@
2827

2928
EPOCH_REGEX = r'^(\d+):(.+)'
3029

31-
logging.basicConfig(
32-
level=logging.INFO,
33-
format='%(asctime)s -> %(levelname)s: %(message)s',
34-
datefmt='%Y-%m-%d %H:%M:%S',
35-
stream=sys.stderr)
36-
logger = logging.getLogger()
30+
logger = logging.getLogger("command")
3731

3832

3933
class Command(BaseCommand):

devel/management/commands/readlinks.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,14 @@
11
import logging
22
import os
33
import re
4-
import sys
54
import tarfile
65

76
from django.core.management.base import BaseCommand, CommandError
87

98
from main.models import Repo, Package, Soname
109

1110

12-
logging.basicConfig(
13-
level=logging.INFO,
14-
format='%(asctime)s -> %(levelname)s: %(message)s',
15-
datefmt='%Y-%m-%d %H:%M:%S',
16-
stream=sys.stderr)
17-
logger = logging.getLogger()
11+
logger = logging.getLogger("command")
1812

1913

2014
class Command(BaseCommand):

devel/management/commands/readlinks_inotify.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import logging
22
import pyinotify
3-
import sys
43
import threading
54

65
from django.core.management.base import BaseCommand, CommandError
@@ -10,12 +9,7 @@
109
from .readlinks import read_links
1110
from .archweb_inotify import EventHandler
1211

13-
logging.basicConfig(
14-
level=logging.INFO,
15-
format='%(asctime)s -> %(levelname)s: %(message)s',
16-
datefmt='%Y-%m-%d %H:%M:%S',
17-
stream=sys.stderr)
18-
logger = logging.getLogger()
12+
logger = logging.getLogger("command")
1913

2014

2115
def wrapper_read_links(arch, filepath, obj):

devel/management/commands/rematch_developers.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,14 @@
1414
from django.core.management.base import BaseCommand
1515
from django.db import transaction
1616

17-
import sys
1817
import logging
1918

2019
from devel.utils import UserFinder
2120
from main.models import Package
2221
from packages.models import FlagRequest
2322

24-
logging.basicConfig(
25-
level=logging.INFO,
26-
format='%(asctime)s -> %(levelname)s: %(message)s',
27-
datefmt='%Y-%m-%d %H:%M:%S',
28-
stream=sys.stderr)
29-
logger = logging.getLogger()
23+
24+
logger = logging.getLogger("command")
3025

3126

3227
class Command(BaseCommand):

devel/management/commands/reporead.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import io
2020
import os
2121
import re
22-
import sys
2322
import xtarfile as tarfile
2423
import logging
2524
from datetime import datetime
@@ -37,14 +36,10 @@
3736
from packages.utils import parse_version
3837

3938

40-
logging.basicConfig(
41-
level=logging.WARNING,
42-
format='%(asctime)s -> %(levelname)s: %(message)s',
43-
datefmt='%Y-%m-%d %H:%M:%S',
44-
stream=sys.stderr)
4539
TRACE = 5
4640
logging.addLevelName(TRACE, 'TRACE')
47-
logger = logging.getLogger()
41+
logger = logging.getLogger("command")
42+
logger.setLevel(logging.WARNING)
4843

4944

5045
class Command(BaseCommand):

devel/management/commands/reporead_inotify.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
import logging
1818
import pyinotify
19-
import sys
2019
import threading
2120

2221
from django.core.management.base import BaseCommand, CommandError
@@ -26,12 +25,9 @@
2625
from .reporead import read_repo
2726
from .archweb_inotify import EventHandler
2827

29-
logging.basicConfig(
30-
level=logging.WARNING,
31-
format='%(asctime)s -> %(levelname)s: %(message)s',
32-
datefmt='%Y-%m-%d %H:%M:%S',
33-
stream=sys.stderr)
34-
logger = logging.getLogger()
28+
29+
logger = logging.getLogger("command")
30+
logger.setLevel(logging.WARNING)
3531

3632

3733
class Command(BaseCommand):

devel/management/commands/retire_user.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,15 @@
99
"""
1010

1111
import logging
12-
import sys
1312

1413
from django.contrib.auth.models import User, Group
1514
from django.core.management.base import BaseCommand, CommandError
1615

1716
from devel.models import UserProfile
1817

1918

20-
logging.basicConfig(
21-
level=logging.WARNING,
22-
format=u'%(asctime)s -> %(levelname)s: %(message)s',
23-
datefmt=u'%Y-%m-%d %H:%M:%S',
24-
stream=sys.stderr)
25-
logger = logging.getLogger()
19+
logger = logging.getLogger("command")
20+
logger.setLevel(logging.WARNING)
2621

2722
MAPPING = {
2823
'Developers': 'Retired Developers',

0 commit comments

Comments
 (0)