Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
Nuovo sito
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
16
Issues
16
List
Boards
Labels
Milestones
Merge Requests
2
Merge Requests
2
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Gruppo Web
Nuovo sito
Commits
1f09996e
Commit
1f09996e
authored
Dec 01, 2023
by
shadMod
💬
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added set_log_config() to set dictConfig()
parent
27834661
Pipeline
#353
passed with stage
in 0 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
0 deletions
+47
-0
uitwww/__init__.py
uitwww/__init__.py
+47
-0
No files found.
uitwww/__init__.py
View file @
1f09996e
...
@@ -29,6 +29,8 @@ from . import pages
...
@@ -29,6 +29,8 @@ from . import pages
from
.
import
redirects
from
.
import
redirects
from
.
import
utils
from
.
import
utils
from
logging.config
import
dictConfig
def
create_app
(
data_path
,
debug
=
False
):
def
create_app
(
data_path
,
debug
=
False
):
"""Create a new instance of the application"""
"""Create a new instance of the application"""
...
@@ -43,6 +45,7 @@ def create_app(data_path, debug=False):
...
@@ -43,6 +45,7 @@ def create_app(data_path, debug=False):
# Prepare the data directory
# Prepare the data directory
init_data_directory
(
data_path
)
init_data_directory
(
data_path
)
set_log_config
(
data_path
)
# Load the secret key
# Load the secret key
with
open
(
os
.
path
.
join
(
data_path
,
"secret_key"
))
as
fn
:
with
open
(
os
.
path
.
join
(
data_path
,
"secret_key"
))
as
fn
:
...
@@ -113,3 +116,47 @@ def init_data_downloads(data_path, debug=False):
...
@@ -113,3 +116,47 @@ def init_data_downloads(data_path, debug=False):
if
debug
is
False
:
if
debug
is
False
:
# mk cache file
# mk cache file
download_inst
.
store_cache_file
()
download_inst
.
store_cache_file
()
def
set_log_config
(
data_path
):
dir_log
=
os
.
path
.
join
(
data_path
,
"logs"
)
os
.
makedirs
(
dir_log
,
exist_ok
=
True
)
dictConfig
(
{
"version"
:
1
,
"formatters"
:
{
"default"
:
{
"format"
:
"[%(asctime)s %(levelname)s] %(module)s: %(message)s"
,
"datefmt"
:
"%d/%m/%Y %H:%M:%S"
,
}
},
"handlers"
:
{
"console"
:
{
"class"
:
"logging.StreamHandler"
,
"stream"
:
"ext://sys.stdout"
,
},
"file"
:
{
"class"
:
"logging.FileHandler"
,
"filename"
:
os
.
path
.
join
(
dir_log
,
"access"
),
"formatter"
:
"default"
},
"error_file"
:
{
"class"
:
"logging.FileHandler"
,
"filename"
:
os
.
path
.
join
(
dir_log
,
"error.log"
),
"formatter"
:
"default"
},
},
"root"
:
{
"level"
:
"DEBUG"
,
"handlers"
:
[
"console"
,
"file"
]
},
"loggers"
:
{
"errors"
:
{
"level"
:
"ERROR"
,
"handlers"
:
[
"error_file"
],
"propagate"
:
False
,
}
},
}
)
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