-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ADD extra_info parameter to Logger.benchmark
- Loading branch information
Showing
3 changed files
with
37 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,29 @@ | ||
|
||
|
||
from curses.ascii import US | ||
import imp | ||
import super_py as sp | ||
import time | ||
|
||
|
||
class User: | ||
def __init__(self, name): | ||
self.name = name | ||
|
||
|
||
log = sp.logging.Logger("main", files=["main.log"], ts_color="bright_green") | ||
log_combined = sp.logging.Logger("combined", files=["combined.log"], ts_color="bright_orange") | ||
|
||
|
||
log("hi") | ||
user = User("John Doe") | ||
|
||
|
||
@log_combined.benchmark(with_args=[0], with_kwargs=["a"]) | ||
@log.benchmark(with_args=[0, 1], with_kwargs=["three", "four"]) | ||
@log.benchmark(with_args=[0, 1], with_kwargs=["three", "four"], extra_info=[lambda: user.name, lambda: time.time()]) | ||
def wait_500ms(one, two, *, three, four): | ||
time.sleep(one) | ||
return "done" | ||
|
||
|
||
print(wait_500ms(1.3, 20, three=30, four=40)) | ||
user.name = "Jane Doe" | ||
print(wait_500ms(0.01, 20, three=30, four=40)) |