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,7 +2,7 @@ | ||
2 | "cells": [ | 2 | "cells": [ |
3 | { | 3 | { |
4 | "cell_type": "code", | 4 | "cell_type": "code", |
5 | - "execution_count": 1, | 5 | + "execution_count": 2, |
6 | "id": "edacfdd9-6a75-4936-a22f-60f7ecc81c7e", | 6 | "id": "edacfdd9-6a75-4936-a22f-60f7ecc81c7e", |
7 | "metadata": {}, | 7 | "metadata": {}, |
8 | "outputs": [], | 8 | "outputs": [], |
@@ -25,13 +25,12 @@ | @@ -25,13 +25,12 @@ | ||
25 | " get_data_for_target,\\\n", | 25 | " get_data_for_target,\\\n", |
26 | " FILE_DATE_FMT,\\\n", | 26 | " FILE_DATE_FMT,\\\n", |
27 | " generate_csv_contents,\\\n", | 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 | "cell_type": "code", | 32 | "cell_type": "code", |
34 | - "execution_count": 2, | 33 | + "execution_count": 3, |
35 | "id": "65ed1f94-a88d-40e3-a061-47e5af065aba", | 34 | "id": "65ed1f94-a88d-40e3-a061-47e5af065aba", |
36 | "metadata": {}, | 35 | "metadata": {}, |
37 | "outputs": [ | 36 | "outputs": [ |
@@ -3723,7 +3722,7 @@ | @@ -3723,7 +3722,7 @@ | ||
3723 | }, | 3722 | }, |
3724 | { | 3723 | { |
3725 | "cell_type": "code", | 3724 | "cell_type": "code", |
3726 | - "execution_count": 3, | 3725 | + "execution_count": 4, |
3727 | "id": "b2764a65-b9e9-43c7-8335-9a2ad2a90c8a", | 3726 | "id": "b2764a65-b9e9-43c7-8335-9a2ad2a90c8a", |
3728 | "metadata": {}, | 3727 | "metadata": {}, |
3729 | "outputs": [ | 3728 | "outputs": [ |
@@ -7416,7 +7415,7 @@ | @@ -7416,7 +7415,7 @@ | ||
7416 | }, | 7415 | }, |
7417 | { | 7416 | { |
7418 | "cell_type": "code", | 7417 | "cell_type": "code", |
7419 | - "execution_count": 4, | 7418 | + "execution_count": 5, |
7420 | "id": "cd34c1c8-b30e-4cdb-ae32-66e5de092c4f", | 7419 | "id": "cd34c1c8-b30e-4cdb-ae32-66e5de092c4f", |
7421 | "metadata": {}, | 7420 | "metadata": {}, |
7422 | "outputs": [ | 7421 | "outputs": [ |
@@ -7462,14 +7461,6 @@ | @@ -7462,14 +7461,6 @@ | ||
7462 | " _df = amda.get_data(_id, start, stop).to_dataframe()\n", | 7461 | " _df = amda.get_data(_id, start, stop).to_dataframe()\n", |
7463 | " print(_df.size)" | 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 | "metadata": { | 7466 | "metadata": { |
web/run.py
@@ -74,17 +74,31 @@ LOG_FILE = get_path('run.log') | @@ -74,17 +74,31 @@ LOG_FILE = get_path('run.log') | ||
74 | hp_logger = logging.getLogger("HelioPropa") | 74 | hp_logger = logging.getLogger("HelioPropa") |
75 | hp_logger.setLevel(logging.DEBUG) | 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 | # set file messages depending on env var setting | 82 | # set file messages depending on env var setting |
83 | if DEBUG: | 83 | if DEBUG: |
84 | - logHandler.setLevel(logging.DEBUG) | 84 | + fileHandler.setLevel(logging.DEBUG) |
85 | else: | 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 | # HARDCODED CONFIGURATION ##################################################### | 103 | # HARDCODED CONFIGURATION ##################################################### |
90 | 104 |