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
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
55f33b1b
Unverified
Commit
55f33b1b
authored
4 years ago
by
Katleho Madisa
Browse files
Options
Downloads
Patches
Plain Diff
SAR-149
Validating the params arguments.
parent
5a8e8efb
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/ska/logging/transactions.py
+51
-49
51 additions, 49 deletions
src/ska/logging/transactions.py
with
51 additions
and
49 deletions
src/ska/logging/transactions.py
+
51
−
49
View file @
55f33b1b
...
@@ -5,7 +5,7 @@ import json
...
@@ -5,7 +5,7 @@ import json
import
logging
import
logging
import
os
import
os
from
typing
import
Text
from
typing
import
Mapping
,
Text
from
ska.skuid.client
import
SkuidClient
from
ska.skuid.client
import
SkuidClient
...
@@ -64,15 +64,15 @@ class Transaction:
...
@@ -64,15 +64,15 @@ class Transaction:
transaction_id
:
str
=
""
,
transaction_id
:
str
=
""
,
transaction_id_key
:
str
=
"
transaction_id
"
,
transaction_id_key
:
str
=
"
transaction_id
"
,
):
):
if
not
isinstance
(
params
,
Mapping
):
raise
TransactionParamsError
(
"
params must be dict-like (Mapping)
"
)
# Get the root logger
# Get the root logger
self
.
logger
=
logging
.
getLogger
()
self
.
logger
=
logging
.
getLogger
()
self
.
_name
=
name
self
.
_name
=
name
self
.
_params
=
params
self
.
_params
=
params
self
.
_transaction_id_key
=
transaction_id_key
self
.
_transaction_id_key
=
transaction_id_key
self
.
_transaction_id
=
(
self
.
_transaction_id
=
transaction_id
if
self
.
_is_valid_id
(
transaction_id
)
else
""
transaction_id
if
self
.
_is_valid_id
(
transaction_id
)
else
""
)
if
not
self
.
_transaction_id
:
if
not
self
.
_transaction_id
:
self
.
_transaction_id
=
self
.
_get_from_params_or_generate_new_id
()
self
.
_transaction_id
=
self
.
_get_from_params_or_generate_new_id
()
...
@@ -94,9 +94,7 @@ class Transaction:
...
@@ -94,9 +94,7 @@ class Transaction:
def
__exit__
(
self
,
exc_type
,
exc_val
,
exc_tb
):
def
__exit__
(
self
,
exc_type
,
exc_val
,
exc_tb
):
if
exc_type
:
if
exc_type
:
self
.
logger
.
exception
(
self
.
logger
.
exception
(
f
"
Transaction[
{
self
.
_transaction_id
}
]: Exception[
{
self
.
_name
}
]
"
)
f
"
Transaction[
{
self
.
_transaction_id
}
]: Exception[
{
self
.
_name
}
]
"
)
self
.
logger
.
info
(
f
"
Transaction[
{
self
.
_transaction_id
}
]: Exit[
{
self
.
_name
}
]
"
)
self
.
logger
.
info
(
f
"
Transaction[
{
self
.
_transaction_id
}
]: Exit[
{
self
.
_name
}
]
"
)
...
@@ -161,3 +159,7 @@ class TransactionIdGenerator:
...
@@ -161,3 +159,7 @@ class TransactionIdGenerator:
def
next
(
self
):
def
next
(
self
):
return
self
.
_get_id
()
return
self
.
_get_id
()
class
TransactionParamsError
(
TypeError
):
"""
Invalid data type for transaction parameters.
"""
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