Skip to content

Commit

Permalink
processor_output -> job_output / override all log flags by 'all'
Browse files Browse the repository at this point in the history
  • Loading branch information
puhitaku committed Jun 13, 2020
1 parent 41b1dc2 commit a54a83d
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 15 deletions.
6 changes: 3 additions & 3 deletions r3build.def.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ dispatched_events.type = "bool"
dispatched_events.default = false
dispatched_events.description = "Show events dispatched to processors."

processor_output.type = "bool"
processor_output.default = true
processor_output.description = "Show the output of the executed processor."
job_output.type = "bool"
job_output.default = true
job_output.description = "Show the output of the executed processor."

result.type = "bool"
result.default = true
Expand Down
4 changes: 2 additions & 2 deletions r3build.skeleton.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
# dispatched_events (bool)
# - Show events dispatched to processors.
#
# processor_output (bool)
# job_output (bool)
# - Show the output of the executed processor.
#
# result (bool)
Expand All @@ -40,7 +40,7 @@ accepted_events = false
rate_limited_events = false
filtered_events = false
dispatched_events = false
processor_output = true
job_output = true
result = true
time = true

Expand Down
14 changes: 10 additions & 4 deletions r3build/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def dispatch(self, event):
self._log_filtered_event(event)
return False

if self._root_config.log.all or self._root_config.log.dispatched_events:
if self._root_config.log.dispatched_events:
print(f'\n >> R3BUILD >> detected a change for job "{self.name}" >>\n')

start = datetime.now()
Expand All @@ -85,11 +85,11 @@ def dispatch(self, event):

info = []

if self._root_config.log.all or self._root_config.log.result:
if self._root_config.log.result:
mes = 'SUCCEEDED' if result else 'FAILED'
info.append(f'has {mes}')

if self._root_config.log.all or self._root_config.log.time:
if self._root_config.log.time:
h = floor(diff / timedelta(hours=1))
m = floor(diff / timedelta(minutes=1)) % 60
s = floor(diff / timedelta(seconds=1)) % 60
Expand Down Expand Up @@ -127,7 +127,7 @@ def _filter_when(self, when, event):
return when == event.event_type

def _log_filtered_event(self, event):
if self._root_config.log.all or self._root_config.log.filtered_events:
if self._root_config.log.filtered_events:
print(f'Filtered event: {event}')

@staticmethod
Expand All @@ -154,6 +154,12 @@ def __init__(self, raw_dict):

super().__init__('root', dict())
self.log = Log('log', raw_dict.get('log', dict()))
if self.log.all:
self.log.accepted_events = True
self.log.rate_limited_events = True
self.log.filtered_events = True
self.log.dispatched_events = True

self.event = Event('event', raw_dict.get('event', dict()))

self.job = []
Expand Down
4 changes: 2 additions & 2 deletions r3build/config_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Log(AccessValidator):
"all",
"dispatched_events",
"filtered_events",
"processor_output",
"job_output",
"rate_limited_events",
"result",
"time",
Expand All @@ -21,7 +21,7 @@ class Log(AccessValidator):
rate_limited_events: bool = False
filtered_events: bool = False
dispatched_events: bool = False
processor_output: bool = True
job_output: bool = True
result: bool = True
time: bool = True

Expand Down
2 changes: 1 addition & 1 deletion r3build/processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def on_change(self, config, event):

def _helper_run(self, cmd, **kwargs):
print(f'Running command: {cmd}')
if self.root_config.log.processor_output:
if self.root_config.log.job_output:
print('Command output:')
else:
kwargs['stdout'] = subprocess.DEVNULL
Expand Down
6 changes: 3 additions & 3 deletions r3build/watcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def run(self):
if elapsed <= self.config.event.rate_limit_duration:
continue
elif self.config.event.ignore_events_while_run and timestamp < last:
if self.config.log.all or self.config.log.rate_limited_events:
if self.config.log.rate_limited_events:
print(f'Ignored event while run: {event}, {timestamp} < {last}')
self.event_buffer.pop(event)
continue
Expand All @@ -124,10 +124,10 @@ def on_any_event(self, event):
If there is an identical event in buffer, it's ignored.
"""
if event in self.event_buffer.events():
if self.config.log.all or self.config.log.rate_limited_events:
if self.config.log.rate_limited_events:
print(f'Rate-limited event: {event}')
return
if self.config.log.all or self.config.log.accepted_events:
if self.config.log.accepted_events:
print(f'Accepted event: {event}')

self.event_buffer.push(event)

0 comments on commit a54a83d

Please sign in to comment.