Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
satella
Manage
Activity
Members
Labels
Plan
Issues
1
Issue boards
Milestones
Wiki
Code
Merge requests
0
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
public
satella
Commits
893c29d2
Commit
893c29d2
authored
12 years ago
by
Piotr Maślanka
Browse files
Options
Downloads
Patches
Plain Diff
Python-dependent string serialization added
parent
a5c08f17
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
instrumentation/logging/logentry.py
+17
-0
17 additions, 0 deletions
instrumentation/logging/logentry.py
instrumentation/unittests/logging.py
+9
-1
9 additions, 1 deletion
instrumentation/unittests/logging.py
with
26 additions
and
1 deletion
instrumentation/logging/logentry.py
+
17
−
0
View file @
893c29d2
...
...
@@ -55,6 +55,23 @@ class LogEntry(object):
return
self
def
to_compact
(
self
):
"""
Serializes this as Python-specific string
"""
return
pickle
.
dumps
(
(
self
.
when
,
self
.
who
,
self
.
tags
,
self
.
main_attachment
,
self
.
attachments
),
pickle
.
HIGHEST_PROTOCOL
)
@staticmethod
def
from_compact
(
p
):
"""
@param p: str
"""
when
,
who
,
tags
,
main_attachment
,
attachments
=
pickle
.
loads
(
p
)
le
=
LogEntry
(
who
,
tags
,
when
).
attach
(
main_attachment
)
for
k
,
v
in
attachments
.
iteritems
():
le
.
attach
(
k
,
v
)
return
le
def
to_JSON
(
self
):
"""
Serializes this object to JSON.
"""
return
json
.
dumps
({
...
...
This diff is collapsed.
Click to expand it.
instrumentation/unittests/logging.py
+
9
−
1
View file @
893c29d2
...
...
@@ -5,7 +5,15 @@ import unittest
class
LogsetTest
(
unittest
.
TestCase
):
def
test_serialization
(
self
):
def
test_compact_serialization
(
self
):
k
=
LogEntry
(
'
a.b
'
,
'
a b
'
).
attach
(
'
stefan
'
,
'
nope
'
)
k
=
LogEntry
.
from_compact
(
k
.
to_compact
())
self
.
assertEquals
(
k
.
attachments
[
'
stefan
'
],
'
nope
'
)
def
test_JSON_serialization
(
self
):
k
=
LogEntry
(
'
a.b
'
,
'
a b
'
).
attach
(
'
stefan
'
,
'
nope
'
)
k
=
LogEntry
.
from_JSON
(
k
.
to_JSON
())
...
...
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