Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
aura-engine
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Lars Kruse
aura-engine
Commits
5c0a4748
Commit
5c0a4748
authored
5 years ago
by
David Trattnig
Browse files
Options
Downloads
Patches
Plain Diff
Extended logger to allow several instances.
parent
82f4dd38
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
libraries/base/logger.py
+41
-24
41 additions, 24 deletions
libraries/base/logger.py
with
41 additions
and
24 deletions
libraries/base/logger.py
+
41
−
24
View file @
5c0a4748
#
#
e
ngine
#
Aura E
ngine
#
# Playout Daemon for autoradio project
# Copyright (C) 2017-2020
# David Trattnig <david.trattnig@subsquare.at>
# Gottfried Gaisbauer <gottfried.gaisbauer@servus.at>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Copyright (C) 2017-2018 Gottfried Gaisbauer <gottfried.gaisbauer@servus.at>
#
# This file is part of engine.
#
# engine is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# any later version.
#
# engine is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with engine. If not, see <http://www.gnu.org/licenses/>.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import
logging
...
...
@@ -28,19 +24,40 @@ from libraries.base.config import AuraConfig
class
AuraLogger
():
"""
AuraLogger Class
Logger for all Aura Engine components. The default
logger is `AuraEngine`. Other loggers are defined
by passing a custom name on instantiation.
The logger respects the log-level as defined in the
engine
'
s configuration file.
"""
config
=
None
logger
=
None
def
__init__
(
self
,
config
):
def
__init__
(
self
,
config
,
name
=
"
AuraEngine
"
):
"""
Constructor to create a new logger defined by
the passed name.
Args:
name (String): The name of the logger
"""
self
.
config
=
config
self
.
__create_logger
(
name
)
self
.
__create_logger
(
"
AuraEngine
"
)
def
__create_logger
(
self
,
name
):
"""
Creates the logger instance for AuraEngine
:param name: LoggerName
:return:
Creates the logger instance for the given name.
Args:
name (String): The name of the logger
"""
lvl
=
self
.
config
.
get
(
"
loglevel
"
)
...
...
@@ -50,7 +67,7 @@ class AuraLogger():
if
not
self
.
logger
.
hasHandlers
():
# create file handler for logger
file_handler
=
logging
.
FileHandler
(
self
.
config
.
get
(
"
logdir
"
)
+
"
/
engine
.log
"
)
file_handler
=
logging
.
FileHandler
(
self
.
config
.
get
(
"
logdir
"
)
+
"
/
"
+
name
+
"
.log
"
)
file_handler
.
setLevel
(
lvl
)
# create stream handler for logger
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment