Skip to content

Commit

Permalink
renamed @logging decorator to @trace, style changes
Browse files Browse the repository at this point in the history
  • Loading branch information
angelala3252 committed Jun 18, 2023
1 parent 70bf019 commit db24c49
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions openadapt/record.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,10 @@ def args_to_str(*args):


def kwargs_to_str(**kwargs):
ret = ""
for k, v in kwargs.items():
ret += f"{k}={v},"
return ",".join([f"{k}={v}" for k, v in kwargs.items()])

return ret[:-1]


def logging(logger):
def trace(logger):
def decorator(func):
@functools.wraps(func)
def wrapper_logging(*args, **kwargs):
Expand Down Expand Up @@ -84,7 +80,7 @@ def process_event(event, write_q, write_fn, recording_timestamp, perf_q):
write_fn(recording_timestamp, event, perf_q)


@logging(logger)
@trace(logger)
def process_events(
event_q: queue.Queue,
screen_write_q: multiprocessing.Queue,
Expand Down Expand Up @@ -226,7 +222,7 @@ def write_window_event(
perf_q.put((event.type, event.timestamp, utils.get_timestamp()))


@logging(logger)
@trace(logger)
def write_events(
event_type: str,
write_fn: Callable,
Expand Down Expand Up @@ -388,7 +384,7 @@ def read_screen_events(
logger.info("done")


@logging(logger)
@trace(logger)
def read_window_events(
event_q: queue.Queue,
terminate_event: multiprocessing.Event,
Expand Down Expand Up @@ -436,7 +432,7 @@ def read_window_events(
prev_window_data = window_data


@logging(logger)
@trace(logger)
def performance_stats_writer (
perf_q: multiprocessing.Queue,
recording_timestamp: float,
Expand Down Expand Up @@ -471,7 +467,7 @@ def performance_stats_writer (
logger.info("performance stats writer done")


@logging(logger)
@trace(logger)
def create_recording(
task_description: str,
) -> Dict[str, Any]:
Expand Down Expand Up @@ -548,7 +544,7 @@ def read_mouse_events(
mouse_listener.stop()


@logging(logger)
@trace(logger)
def record(
task_description: str,
):
Expand Down

0 comments on commit db24c49

Please sign in to comment.