Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
ska-logging
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
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
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
LOFAR2.0
ska-logging
Commits
e6a835fd
Commit
e6a835fd
authored
5 years ago
by
Anton Joubert
Browse files
Options
Downloads
Patches
Plain Diff
SAR-55
Revert add static tag to formatter
Turns out this is not that useful for Tango SKABaseDevice.
parent
102b269f
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
ska_logging/__init__.py
+0
-4
0 additions, 4 deletions
ska_logging/__init__.py
ska_logging/configuration.py
+4
-29
4 additions, 29 deletions
ska_logging/configuration.py
tests/test_configuration.py
+1
-14
1 addition, 14 deletions
tests/test_configuration.py
with
5 additions
and
47 deletions
ska_logging/__init__.py
+
0
−
4
View file @
e6a835fd
...
@@ -5,8 +5,6 @@
...
@@ -5,8 +5,6 @@
__all__
=
(
__all__
=
(
"
configure_logging
"
,
"
configure_logging
"
,
"
get_default_formatter
"
,
"
get_default_formatter
"
,
"
SkaLoggingError
"
,
"
SkaLoggingTagsFormatError
"
,
)
)
__author__
=
"
Anton Joubert
"
__author__
=
"
Anton Joubert
"
__email__
=
"
ajoubert+ska@ska.ac.za
"
__email__
=
"
ajoubert+ska@ska.ac.za
"
...
@@ -15,8 +13,6 @@ __email__ = "ajoubert+ska@ska.ac.za"
...
@@ -15,8 +13,6 @@ __email__ = "ajoubert+ska@ska.ac.za"
from
.configuration
import
(
from
.configuration
import
(
configure_logging
,
configure_logging
,
get_default_formatter
,
get_default_formatter
,
SkaLoggingError
,
SkaLoggingTagsFormatError
,
)
)
...
...
This diff is collapsed.
Click to expand it.
ska_logging/configuration.py
+
4
−
29
View file @
e6a835fd
...
@@ -7,14 +7,6 @@ import logging.config
...
@@ -7,14 +7,6 @@ import logging.config
import
time
import
time
class
SkaLoggingError
(
Exception
):
"""
Base class for all SKA Logger exceptions.
"""
class
SkaLoggingTagsFormatError
(
SkaLoggingError
):
"""
Invalid format for the
'
tags
'
field string.
"""
class
_UTCFormatter
(
logging
.
Formatter
):
class
_UTCFormatter
(
logging
.
Formatter
):
converter
=
time
.
gmtime
converter
=
time
.
gmtime
...
@@ -46,7 +38,6 @@ _FORMAT_STR_WITH_TAGS = (
...
@@ -46,7 +38,6 @@ _FORMAT_STR_WITH_TAGS = (
"
%(message)s
"
"
%(message)s
"
)
)
_INVALID_TAG_CHARS
=
(
"
|
"
,
"
%
"
)
_LOGGING_CONFIG
=
{
_LOGGING_CONFIG
=
{
"
version
"
:
1
,
"
version
"
:
1
,
...
@@ -123,33 +114,17 @@ def get_default_formatter(tags=False):
...
@@ -123,33 +114,17 @@ def get_default_formatter(tags=False):
Parameters
Parameters
----------
----------
tags : bool or str, optional
tags : bool, optional
If boolean, then treated as a toggle:
If true, then include the
"
tags
"
field in the format string. This requires
- True: include the
"
tags
"
field in the format string. This requires
a tags filter to be linked to the corresponding handler.
a tags filter to be linked to the corresponding handler.
- False: exclude the
"
tags
"
field from the format string.
If string, then it is a static tag. Instead of using a logging filter, the
formatter will just use this static string for the
"
tags
"
field directly.
Returns
Returns
-------
-------
logging.Formatter
logging.Formatter
A new default formatter.
A new default formatter.
Raises
------
SkaLoggingTagsFormatError:
If the static tags string has an invalid format.
"""
"""
if
isinstance
(
tags
,
str
):
if
tags
:
invalid_chars
=
[
c
for
c
in
_INVALID_TAG_CHARS
if
c
in
tags
]
if
invalid_chars
:
raise
SkaLoggingTagsFormatError
(
"
Invalid char(s) {} in tags: {!r}
"
.
format
(
invalid_chars
,
tags
)
)
format_str
=
_FORMAT_STR_WITH_TAGS
.
replace
(
"
%(tags)s
"
,
tags
)
elif
tags
:
format_str
=
_FORMAT_STR_WITH_TAGS
format_str
=
_FORMAT_STR_WITH_TAGS
else
:
else
:
format_str
=
_FORMAT_STR_NO_TAGS
format_str
=
_FORMAT_STR_NO_TAGS
...
...
This diff is collapsed.
Click to expand it.
tests/test_configuration.py
+
1
−
14
View file @
e6a835fd
...
@@ -9,7 +9,7 @@ import pytest
...
@@ -9,7 +9,7 @@ import pytest
import
ska_logging.configuration
import
ska_logging.configuration
from
ska_logging
import
configure_logging
,
get_default_formatter
,
SkaLoggingTagsFormatError
from
ska_logging
import
configure_logging
,
get_default_formatter
@pytest.fixture
@pytest.fixture
...
@@ -183,19 +183,6 @@ class TestGetDefaultFormatter:
...
@@ -183,19 +183,6 @@ class TestGetDefaultFormatter:
assert
isinstance
(
formatter
,
ska_logging
.
configuration
.
_UTCFormatter
)
assert
isinstance
(
formatter
,
ska_logging
.
configuration
.
_UTCFormatter
)
assert
formatter
.
_fmt
==
ska_logging
.
configuration
.
_FORMAT_STR_WITH_TAGS
assert
formatter
.
_fmt
==
ska_logging
.
configuration
.
_FORMAT_STR_WITH_TAGS
def
test_get_tags_static_string
(
self
):
formatter
=
get_default_formatter
(
tags
=
"
test-key:test-value
"
)
assert
isinstance
(
formatter
,
ska_logging
.
configuration
.
_UTCFormatter
)
tags_format
=
ska_logging
.
configuration
.
_FORMAT_STR_WITH_TAGS
expected_format
=
tags_format
.
replace
(
"
%(tags)s
"
,
"
test-key:test-value
"
)
assert
formatter
.
_fmt
==
expected_format
def
test_get_tags_invalid_static_string
(
self
):
with
pytest
.
raises
(
SkaLoggingTagsFormatError
):
get_default_formatter
(
tags
=
"
no|pipes|allowed
"
)
with
pytest
.
raises
(
SkaLoggingTagsFormatError
):
get_default_formatter
(
tags
=
"
no%percentage%symbols%allowed
"
)
class
TestOverride
:
class
TestOverride
:
"""
Tests for :func:`~ska_logging.configuration._override`.
"""
Tests for :func:`~ska_logging.configuration._override`.
...
...
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