Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
silvio
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
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
Service Desk
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Ulf Liebal
silvio
Commits
de18e68e
Commit
de18e68e
authored
3 years ago
by
Rafael Schimassek
Browse files
Options
Downloads
Patches
Plain Diff
Host message logging is now a public method.
parent
040fed77
Branches
ft-metabolic-model
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/silvio/host.py
+12
-2
12 additions, 2 deletions
src/silvio/host.py
with
12 additions
and
2 deletions
src/silvio/host.py
+
12
−
2
View file @
de18e68e
...
...
@@ -184,6 +184,14 @@ class Host (ABC) :
def
log
(
self
,
text
:
str
,
depth
:
Optional
[
int
]
=
1
)
->
None
:
"""
Log a message in the event log.
"""
self
.
event_log
.
append
(
(
"
-
"
*
depth
)
+
text
)
def
emit
(
self
,
event
:
Event
,
chain
:
List
[
ListenerEntry
]
=
[]
)
->
None
:
"""
Trigger all listeners for a given Event.
...
...
@@ -201,7 +209,7 @@ class Host (ABC) :
# Run the listener with the emitted event and append to chain to keep track.
new_chain
=
chain
+
[
le
]
emit
=
lambda
event
:
self
.
emit
(
event
,
new_chain
)
log
=
lambda
text
:
self
.
event_log
.
append
(
"
-
"
*
len
(
new_chain
)
+
text
)
log
=
lambda
text
:
self
.
log
(
text
,
len
(
new_chain
)
+
1
)
le
.
run
(
event
,
emit
,
log
)
...
...
@@ -219,7 +227,7 @@ class Host (ABC) :
This cannot be included inside the module __init__ because all listeners have to be set.
"""
emit
=
lambda
event
:
self
.
emit
(
event
,
[]
)
log
=
lambda
text
:
self
.
event_log
.
append
(
text
)
log
=
lambda
text
:
self
.
log
(
text
)
for
mod
in
modules
:
mod
.
sync
(
emit
,
log
)
...
...
@@ -233,5 +241,7 @@ class Host (ABC) :
def
print_event_log
(
self
)
->
None
:
print
(
"
Event Log for {}:
"
.
format
(
self
.
name
))
print
(
"
=
"
*
(
len
(
self
.
name
)
+
15
))
for
ev
in
self
.
event_log
:
print
(
ev
)
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