Commit 895cda7948358dcdbd480d7009d4e23bcbb49624
1 parent
3069851e
Exists in
rhitier-dev
New init_console_logger()
Showing
2 changed files
with
25 additions
and
20 deletions
Show diff stats
notebooks/Spz_Method_Speed_Test.ipynb
... | ... | @@ -2,7 +2,7 @@ |
2 | 2 | "cells": [ |
3 | 3 | { |
4 | 4 | "cell_type": "code", |
5 | - "execution_count": 1, | |
5 | + "execution_count": 2, | |
6 | 6 | "id": "edacfdd9-6a75-4936-a22f-60f7ecc81c7e", |
7 | 7 | "metadata": {}, |
8 | 8 | "outputs": [], |
... | ... | @@ -25,13 +25,12 @@ |
25 | 25 | " get_data_for_target,\\\n", |
26 | 26 | " FILE_DATE_FMT,\\\n", |
27 | 27 | " generate_csv_contents,\\\n", |
28 | - " generate_csv_contents_spz,\\\n", | |
29 | - " log" | |
28 | + " generate_csv_contents_spz" | |
30 | 29 | ] |
31 | 30 | }, |
32 | 31 | { |
33 | 32 | "cell_type": "code", |
34 | - "execution_count": 2, | |
33 | + "execution_count": 3, | |
35 | 34 | "id": "65ed1f94-a88d-40e3-a061-47e5af065aba", |
36 | 35 | "metadata": {}, |
37 | 36 | "outputs": [ |
... | ... | @@ -3723,7 +3722,7 @@ |
3723 | 3722 | }, |
3724 | 3723 | { |
3725 | 3724 | "cell_type": "code", |
3726 | - "execution_count": 3, | |
3725 | + "execution_count": 4, | |
3727 | 3726 | "id": "b2764a65-b9e9-43c7-8335-9a2ad2a90c8a", |
3728 | 3727 | "metadata": {}, |
3729 | 3728 | "outputs": [ |
... | ... | @@ -7416,7 +7415,7 @@ |
7416 | 7415 | }, |
7417 | 7416 | { |
7418 | 7417 | "cell_type": "code", |
7419 | - "execution_count": 4, | |
7418 | + "execution_count": 5, | |
7420 | 7419 | "id": "cd34c1c8-b30e-4cdb-ae32-66e5de092c4f", |
7421 | 7420 | "metadata": {}, |
7422 | 7421 | "outputs": [ |
... | ... | @@ -7462,14 +7461,6 @@ |
7462 | 7461 | " _df = amda.get_data(_id, start, stop).to_dataframe()\n", |
7463 | 7462 | " print(_df.size)" |
7464 | 7463 | ] |
7465 | - }, | |
7466 | - { | |
7467 | - "cell_type": "code", | |
7468 | - "execution_count": null, | |
7469 | - "id": "3a210e72-5197-4678-bbbc-f4690e36a35d", | |
7470 | - "metadata": {}, | |
7471 | - "outputs": [], | |
7472 | - "source": [] | |
7473 | 7464 | } |
7474 | 7465 | ], |
7475 | 7466 | "metadata": { | ... | ... |
web/run.py
... | ... | @@ -74,17 +74,31 @@ LOG_FILE = get_path('run.log') |
74 | 74 | hp_logger = logging.getLogger("HelioPropa") |
75 | 75 | hp_logger.setLevel(logging.DEBUG) |
76 | 76 | |
77 | -logHandler = logging.FileHandler(LOG_FILE) | |
78 | -logHandler.setFormatter(logging.Formatter( | |
79 | - "%(asctime)s - %(levelname)s - %(message)s" | |
77 | +fileHandler = logging.FileHandler(LOG_FILE) | |
78 | +fileHandler.setFormatter(logging.Formatter( | |
79 | + "%(asctime)s - %(levelname)s - %(message)s" | |
80 | 80 | )) |
81 | 81 | |
82 | 82 | # set file messages depending on env var setting |
83 | 83 | if DEBUG: |
84 | - logHandler.setLevel(logging.DEBUG) | |
84 | + fileHandler.setLevel(logging.DEBUG) | |
85 | 85 | else: |
86 | - logHandler.setLevel(logging.ERROR) | |
87 | -hp_logger.addHandler(logHandler) | |
86 | + fileHandler.setLevel(logging.ERROR) | |
87 | +hp_logger.addHandler(fileHandler) | |
88 | + | |
89 | + | |
90 | +def init_console_logger(): | |
91 | + consoleHandler = logging.StreamHandler() | |
92 | + if DEBUG: | |
93 | + consoleHandler.setLevel(logging.DEBUG) | |
94 | + else: | |
95 | + consoleHandler.setLevel(logging.ERROR) | |
96 | + formatter = logging.Formatter('CONSOLE: %(levelname)s - %(message)s') | |
97 | + consoleHandler.setFormatter(formatter) | |
98 | + # Add handlers to the logger | |
99 | + hp_logger.addHandler(consoleHandler) | |
100 | + return hp_logger | |
101 | + | |
88 | 102 | |
89 | 103 | # HARDCODED CONFIGURATION ##################################################### |
90 | 104 | ... | ... |