Revize 3d86c8ef
Přidáno uživatelem Martin Forejt před téměř 4 roky(ů)
aswi2021vochomurka/app.py | ||
---|---|---|
1 |
import logging |
|
2 |
|
|
1 | 3 |
from PyQt5.QtWidgets import QApplication |
2 | 4 |
|
3 | 5 |
from aswi2021vochomurka.view.main_view import MainView |
... | ... | |
5 | 7 |
|
6 | 8 |
class Application(QApplication): |
7 | 9 |
def __init__(self, sys_argv): |
10 |
init_logger() |
|
8 | 11 |
super(Application, self).__init__(sys_argv) |
12 |
logging.info('App started') |
|
9 | 13 |
self.main_view = MainView() |
10 | 14 |
self.main_view.show() |
15 |
|
|
16 |
|
|
17 |
def init_logger(): |
|
18 |
logging.basicConfig( |
|
19 |
level=logging.INFO, |
|
20 |
filename='data/app.log', |
|
21 |
format='%(asctime)s %(name)s: %(levelname)-8s %(message)s', |
|
22 |
datefmt='%y-%m-%d %H:%M', |
|
23 |
filemode='w' |
|
24 |
) |
|
25 |
|
|
26 |
console = logging.StreamHandler() |
|
27 |
console.setLevel(logging.INFO) |
|
28 |
formatter = logging.Formatter('%(asctime)s %(name)s: %(levelname)-8s %(message)s') |
|
29 |
console.setFormatter(formatter) |
|
30 |
logging.getLogger('').addHandler(console) |
|
31 |
|
|
32 |
logging.getLogger('apscheduler.scheduler').setLevel(logging.WARNING) |
aswi2021vochomurka/main.py | ||
---|---|---|
4 | 4 |
|
5 | 5 |
|
6 | 6 |
def start(): |
7 |
print("hello world Vochomurka") |
|
8 | 7 |
app = Application(sys.argv) |
9 | 8 |
sys.exit(app.exec_()) |
10 | 9 |
|
Také k dispozici: Unified diff
Re: #8893 - init logger