Ignore any non gerrit lines
[integration/test.git] / tools / distchanges / logg.py
1 # Copyright (c) 2018 Red Hat, Inc. and others.  All rights reserved.
2 #
3 # This program and the accompanying materials are made available under the
4 # terms of the Eclipse Public License v1.0 which accompanies this distribution,
5 # and is available at http://www.eclipse.org/legal/epl-v10.html
6
7 import logging
8
9 logger = None
10 ch = None
11 fh = None
12
13
14 def debug():
15     ch.setLevel(logging.DEBUG)
16     # logger.setLevel(min([ch.level, fh.level]))
17
18
19 class Logger:
20     def __init__(self, console_level=logging.INFO, file_level=logging.DEBUG):
21         global logger
22         global ch
23         global fh
24
25         logger = logging.getLogger()
26         formatter = logging.Formatter('%(asctime)s | %(levelname).3s | %(name)-20s | %(lineno)04d | %(message)s')
27         ch = logging.StreamHandler()
28         ch.setLevel(console_level)
29         ch.setFormatter(formatter)
30         logger.addHandler(ch)
31         fh = logging.FileHandler("/tmp/odltools.txt", "w")
32         fh.setLevel(file_level)
33         fh.setFormatter(formatter)
34         logger.addHandler(fh)
35         logger.setLevel(min([ch.level, fh.level]))