Skip to content

Commit

Permalink
Add duration logging to commands
Browse files Browse the repository at this point in the history
  • Loading branch information
vkottler committed Jul 22, 2024
1 parent 017c6c2 commit aad083c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 2 additions & 0 deletions local/configs/package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
name: runtimepy
version: "{{major}}.{{minor}}.{{patch}}"
description: A framework for implementing Python services.

entry: {{entry}}
time_command: true

requirements:
- vcorelib>=3.3.1
Expand Down
8 changes: 5 additions & 3 deletions runtimepy/entry.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# =====================================
# generator=datazen
# version=3.1.4
# hash=c2bc26deadfa7cc275e815f499693863
# hash=79c31d1280a6e97b5d326aecb758c597
# =====================================

"""
Expand All @@ -10,13 +10,14 @@

# built-in
import argparse
from logging import getLogger
import os
from pathlib import Path
import sys
from typing import List

# third-party
from vcorelib.logging import init_logging, logging_args
from vcorelib.logging import init_logging, log_time, logging_args

# internal
from runtimepy import DESCRIPTION, VERSION
Expand Down Expand Up @@ -68,7 +69,8 @@ def main(argv: List[str] = None) -> int:
os.chdir(args.dir)

# run the application
result = entry(args)
with log_time(getLogger(__name__), "Command"):
result = entry(args)
except SystemExit as exc:
result = 1
if exc.code is not None and isinstance(exc.code, int):
Expand Down

0 comments on commit aad083c

Please sign in to comment.