Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Validata
validata-ui
Commits
580c78c8
Commit
580c78c8
authored
Jun 17, 2019
by
Christophe Benz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add LOG_LEVEL config key
parent
54339067
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
1 deletion
+16
-1
.env.example
.env.example
+2
-0
validata_ui/__init__.py
validata_ui/__init__.py
+4
-1
validata_ui/config.py
validata_ui/config.py
+10
-0
No files found.
.env.example
View file @
580c78c8
# Example config file. Copy and customize this file to ".env". Don't commit ".env".
LOG_LEVEL="INFO"
# For production deployment, see http://flask.pocoo.org/docs/1.0/tutorial/deploy/#configure-the-secret-key
SECRET_KEY="dev"
...
...
validata_ui/__init__.py
View file @
580c78c8
import
json
import
logging
import
os
from
pathlib
import
Path
from
urllib.parse
import
quote_plus
...
...
@@ -11,9 +12,10 @@ from cachetools.func import ttl_cache
import
opendataschema
# Let this import after app initialisation
from
.
import
config
log
=
logging
.
getLogger
(
__name__
)
@
ttl_cache
(
maxsize
=
50
,
ttl
=
5
*
60
)
def
download_with_cache
(
url
):
...
...
@@ -28,6 +30,7 @@ def schema_from_url(url):
# And load schema catalogs which urls are found in config.json
schema_catalog_map
=
{}
if
config
.
HOMEPAGE_CONFIG
:
log
.
info
(
"Initializing homepage sections..."
)
for
section
in
config
.
HOMEPAGE_CONFIG
[
'sections'
]:
if
isinstance
(
section
[
'catalog'
],
str
)
and
section
[
'catalog'
].
startswith
(
'http'
):
code
=
section
[
'code'
]
...
...
validata_ui/config.py
View file @
580c78c8
import
json
import
logging
import
os
import
sys
from
pathlib
import
Path
import
requests
...
...
@@ -11,6 +12,15 @@ log = logging.getLogger(__name__)
load_dotenv
()
LOG_LEVEL
=
os
.
environ
.
get
(
"LOG_LEVEL"
,
"INFO"
)
numeric_log_level
=
getattr
(
logging
,
LOG_LEVEL
.
upper
(),
None
)
if
not
isinstance
(
numeric_log_level
,
int
):
log
.
error
(
'Invalid log level: {}'
.
format
(
LOG_LEVEL
))
logging
.
basicConfig
(
format
=
"%(levelname)s:%(name)s:%(message)s"
,
level
=
numeric_log_level
,
stream
=
sys
.
stderr
,
# script outputs data
)
SECRET_KEY
=
os
.
environ
.
get
(
"SECRET_KEY"
)
or
None
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment