-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Implement Logging of Terminal Output to a .log file. #180
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
876ab24
Implemented logging of terminal output to file.
5611a31
Set default config values for log_to_file, log_dir
e9d9b29
Change default log_dir to ./logs
a6c4151
Bring log-file up to date with Master.
980b947
Merge branch 'master' into log-file
8c771ec
Re-implement logging of Terminal output to log file.
33efe31
Move log _writing_ statements to separate function.
5549f3a
Add a test for logging.
175b6c7
Added test to check if logs generated are same.
aa0415c
Added model log file.
f35032b
Test on this branch
cdce065
Change Regex expression for windows.
219600c
Print log on failure
bb914ef
Print log windows.
7749bf4
Edit regex expression for both unix and windows.
7604d53
Edit regex expression.
366d202
Edit expected log.
b2daaeb
Try stripping whitespace.
44ce406
Move test_logging to a separate file.
40b2b70
Print log for all OS's
6df05c0
Make rules for passing looser.
ad5ae6f
Fix a typo
cabd956
Split string before cleaning.
60a11de
Change testing method for log files.
bd485d8
Remove duplicate test_logging file.
64e8d2a
Move default log directory into media directory.
Aathish04 19a7c7c
Ignored Line Numbers during test.
Aathish04 e63ce10
Allow changing of Max width and height of logs via config files.
Aathish04 53420f0
Implemented word-for-word tests for log file.
Aathish04 e375a48
Merge branch 'master' into log-file
Aathish04 232b7c9
Formatted as per black's wishes.
Aathish04 2329b1a
Merge branch 'log-file' of https://github.com/ManimCommunity/manim in…
Aathish04 fac22b3
Add cfg subcmd case for log_width and height.
Aathish04 1ca28b2
Make regex remove list indicators as well.
Aathish04 cc574f3
Make regex remove timestamps.
Aathish04 1f51a2d
Added a comment about the monstrous regex.
Aathish04 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
---|---|---|
|
@@ -24,3 +24,6 @@ False | |
|
||
|
||
|
||
|
||
|
||
|
This file contains hidden or 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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
INFO Read configuration files: config.py: | ||
INFO scene_file_writer.py: | ||
File ready at | ||
|
This file contains hidden or 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 |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import subprocess | ||
import os | ||
import sys | ||
from shutil import rmtree | ||
import pytest | ||
import re | ||
|
||
|
||
def capture(command, instream=None): | ||
proc = subprocess.Popen( | ||
command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=instream | ||
) | ||
out, err = proc.communicate() | ||
return out, err, proc.returncode | ||
|
||
|
||
def test_logging_to_file(python_version): | ||
"""Test logging Terminal output to a log file. | ||
As some data will differ with each log (the timestamps, file paths, line nums etc) | ||
a regex substitution has been employed to replace the strings that may change with | ||
whitespace. | ||
""" | ||
path_basic_scene = os.path.join("tests", "tests_data", "basic_scenes.py") | ||
path_output = os.path.join("tests_cache", "media_temp") | ||
command = [ | ||
python_version, | ||
"-m", | ||
"manim", | ||
path_basic_scene, | ||
"SquareToCircle", | ||
"-l", | ||
"--log_to_file", | ||
"--log_dir", | ||
os.path.join(path_output, "logs"), | ||
"--media_dir", | ||
path_output, | ||
] | ||
out, err, exitcode = capture(command) | ||
log_file_path = os.path.join(path_output, "logs", "SquareToCircle.log") | ||
assert exitcode == 0, err | ||
assert os.path.exists(log_file_path), err | ||
if sys.platform.startswith("win32") or sys.platform.startswith("cygwin"): | ||
enc = "Windows-1252" | ||
else: | ||
enc = "utf-8" | ||
with open(log_file_path, encoding=enc) as logfile: | ||
logs = logfile.read() | ||
# The following regex pattern selects timestamps, file paths and all numbers.. | ||
pattern = r"(\[?\d+:?]?)|(\['[A-Z]?:?[\/\\].*cfg'])|([A-Z]?:?[\/\\].*mp4)" | ||
|
||
logs = re.sub(pattern, lambda m: " " * len((m.group(0))), logs) | ||
with open( | ||
os.path.join(os.path.dirname(__file__), "expected.txt"), "r" | ||
) as expectedfile: | ||
expected = re.sub( | ||
pattern, lambda m: " " * len((m.group(0))), expectedfile.read() | ||
) | ||
assert logs == expected, logs |
This file contains hidden or 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 |
---|---|---|
|
@@ -4,3 +4,6 @@ write_to_movie = True | |
# write_all = False | ||
save_last_frame = False | ||
# save_pngs = False | ||
|
||
[logger] | ||
log_width = 256 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick : Maybe document this saying that this is provisional.