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
796b75c0
Commit
796b75c0
authored
12 years ago
by
Piotr Maślanka
Browse files
Options
Downloads
Patches
Plain Diff
main_attachment changed to data
parent
893c29d2
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
+7
-7
7 additions, 7 deletions
instrumentation/logging/logentry.py
instrumentation/unittests/logging.py
+1
-1
1 addition, 1 deletion
instrumentation/unittests/logging.py
with
8 additions
and
8 deletions
instrumentation/logging/logentry.py
+
7
−
7
View file @
796b75c0
...
@@ -38,7 +38,7 @@ class LogEntry(object):
...
@@ -38,7 +38,7 @@ class LogEntry(object):
self
.
tags
=
set
(
tags
)
self
.
tags
=
set
(
tags
)
self
.
attachments
=
{}
#: dict(attachment name::str => attachment)
self
.
attachments
=
{}
#: dict(attachment name::str => attachment)
self
.
main_attachment
=
None
#: main attachment
self
.
data
=
None
#: extra data
def
attach
(
self
,
*
args
):
def
attach
(
self
,
*
args
):
"""
"""
...
@@ -47,7 +47,7 @@ class LogEntry(object):
...
@@ -47,7 +47,7 @@ class LogEntry(object):
(first of them will be a str, name of the entry, second one - the data to attach).
(first of them will be a str, name of the entry, second one - the data to attach).
"""
"""
if
len
(
args
)
==
1
:
# Attach an attachment without a name
if
len
(
args
)
==
1
:
# Attach an attachment without a name
self
.
main_attachment
=
args
[
0
]
self
.
data
=
args
[
0
]
elif
len
(
args
)
==
2
:
# Attach a named attachment
elif
len
(
args
)
==
2
:
# Attach a named attachment
self
.
attachments
[
args
[
0
]]
=
args
[
1
]
self
.
attachments
[
args
[
0
]]
=
args
[
1
]
else
:
else
:
...
@@ -59,15 +59,15 @@ class LogEntry(object):
...
@@ -59,15 +59,15 @@ class LogEntry(object):
def
to_compact
(
self
):
def
to_compact
(
self
):
"""
Serializes this as Python-specific string
"""
"""
Serializes this as Python-specific string
"""
return
pickle
.
dumps
(
return
pickle
.
dumps
(
(
self
.
when
,
self
.
who
,
self
.
tags
,
self
.
main_attachment
,
self
.
attachments
),
(
self
.
when
,
self
.
who
,
self
.
tags
,
self
.
data
,
self
.
attachments
),
pickle
.
HIGHEST_PROTOCOL
pickle
.
HIGHEST_PROTOCOL
)
)
@staticmethod
@staticmethod
def
from_compact
(
p
):
def
from_compact
(
p
):
"""
@param p: str
"""
"""
@param p: str
"""
when
,
who
,
tags
,
main_attachment
,
attachments
=
pickle
.
loads
(
p
)
when
,
who
,
tags
,
data
,
attachments
=
pickle
.
loads
(
p
)
le
=
LogEntry
(
who
,
tags
,
when
).
attach
(
main_attachment
)
le
=
LogEntry
(
who
,
tags
,
when
).
attach
(
data
)
for
k
,
v
in
attachments
.
iteritems
():
for
k
,
v
in
attachments
.
iteritems
():
le
.
attach
(
k
,
v
)
le
.
attach
(
k
,
v
)
return
le
return
le
...
@@ -78,7 +78,7 @@ class LogEntry(object):
...
@@ -78,7 +78,7 @@ class LogEntry(object):
'
when
'
:
self
.
when
,
'
when
'
:
self
.
when
,
'
who
'
:
self
.
who
,
'
who
'
:
self
.
who
,
'
tags
'
:
sorted
(
self
.
tags
),
'
tags
'
:
sorted
(
self
.
tags
),
'
main
'
:
self
.
main_attachment
,
'
data
'
:
self
.
data
,
'
attachments
'
:
dict
((
'
attachments
'
:
dict
((
(
name
,
base64
.
b64encode
(
pickle
.
dumps
(
value
,
pickle
.
HIGHEST_PROTOCOL
)))
(
name
,
base64
.
b64encode
(
pickle
.
dumps
(
value
,
pickle
.
HIGHEST_PROTOCOL
)))
for
name
,
value
in
self
.
attachments
.
iteritems
()
for
name
,
value
in
self
.
attachments
.
iteritems
()
...
@@ -93,7 +93,7 @@ class LogEntry(object):
...
@@ -93,7 +93,7 @@ class LogEntry(object):
Know that main_attachment
'
s str
'
s will get converted to Unicode, due to how JSON works.
Know that main_attachment
'
s str
'
s will get converted to Unicode, due to how JSON works.
@type jsonstr: str
"""
@type jsonstr: str
"""
jo
=
json
.
loads
(
jsonstr
)
jo
=
json
.
loads
(
jsonstr
)
le
=
LogEntry
(
str
(
jo
[
'
who
'
]),
map
(
str
,
jo
[
'
tags
'
]),
jo
[
'
when
'
]).
attach
(
jo
[
'
main
'
])
le
=
LogEntry
(
str
(
jo
[
'
who
'
]),
map
(
str
,
jo
[
'
tags
'
]),
jo
[
'
when
'
]).
attach
(
jo
[
'
data
'
])
for
aname
,
avs
in
jo
[
'
attachments
'
].
iteritems
():
for
aname
,
avs
in
jo
[
'
attachments
'
].
iteritems
():
le
.
attach
(
aname
,
pickle
.
loads
(
base64
.
b64decode
(
avs
)))
le
.
attach
(
aname
,
pickle
.
loads
(
base64
.
b64decode
(
avs
)))
return
le
return
le
This diff is collapsed.
Click to expand it.
instrumentation/unittests/logging.py
+
1
−
1
View file @
796b75c0
...
@@ -58,7 +58,7 @@ class LoggingTest(unittest.TestCase):
...
@@ -58,7 +58,7 @@ class LoggingTest(unittest.TestCase):
le
.
attach
(
'
test string
'
,
'
hello world
'
)
le
.
attach
(
'
test string
'
,
'
hello world
'
)
self
.
assertEquals
(
len
(
le
.
attachments
),
1
)
self
.
assertEquals
(
len
(
le
.
attachments
),
1
)
self
.
assertEquals
(
le
.
main_attachment
,
'
hello world
'
)
self
.
assertEquals
(
le
.
data
,
'
hello world
'
)
self
.
assertEquals
(
set
(
le
.
tags
),
set
((
'
satella
'
,
'
test
'
)))
self
.
assertEquals
(
set
(
le
.
tags
),
set
((
'
satella
'
,
'
test
'
)))
# test fluid interface of .attach()
# test fluid interface of .attach()
...
...
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