-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add example scripts demonstrating the usage of `ShellLogger`. * Add the examples to the documentation, along with screenshots of the generated log file. * Run the examples in the pipeline to ensure they always work.
- Loading branch information
Showing
13 changed files
with
242 additions
and
24 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
log* | ||
flex* |
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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/usr/bin/env python3 | ||
|
||
from pathlib import Path | ||
from shelllogger import ShellLogger | ||
|
||
sl = ShellLogger("Build Flex", | ||
Path.cwd() / f"log_{Path(__file__).stem}") | ||
sl.print("This example demonstrates cloning, configuring, and building the " | ||
"Flex tool.") | ||
sl.log("Clone the Flex repository.", | ||
"git clone --depth 1 --branch flex-2.5.39 " | ||
"/~https://github.com/westes/flex.git flex-2.5.39", live_stdout=True, | ||
live_stderr=True) | ||
sl.log("Run Autogen", "./autogen.sh", cwd=Path.cwd()/"flex-2.5.39", | ||
live_stdout=True, live_stderr=True) | ||
sl.log("Configure Flex", "./configure --prefix=$(dirname $(pwd))/flex", | ||
cwd=Path.cwd()/"flex-2.5.39", live_stdout=True, live_stderr=True, | ||
measure=["cpu", "memory", "disk"]) | ||
sl.log("Build libcompat.la", "make libcompat.la", | ||
cwd=Path.cwd()/"flex-2.5.39/lib", live_stdout=True, live_stderr=True, | ||
measure=["cpu", "memory", "disk"]) | ||
sl.log("Build & Install Flex", "make install-exec", | ||
cwd=Path.cwd()/"flex-2.5.39", live_stdout=True, live_stderr=True, | ||
measure=["cpu", "memory", "disk"]) | ||
sl.finalize() | ||
print(f"Open {sl.html_file} to view the log.") |
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/usr/bin/env python3 | ||
|
||
from pathlib import Path | ||
from shelllogger import ShellLogger | ||
|
||
sl = ShellLogger("Hello ShellLogger", | ||
Path.cwd() / f"log_{Path(__file__).stem}") | ||
sl.print("This example demonstrates logging information solely to the HTML " | ||
"log file.") | ||
sl.log("Greet everyone to make them feel welcome.", "echo 'Hello World'") | ||
sl.log("Tell everyone who you are, but from a different directory.", "whoami", | ||
cwd=Path.cwd().parent) | ||
sl.finalize() | ||
print(f"Open {sl.html_file} to view the log.") |
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/usr/bin/env python3 | ||
|
||
from pathlib import Path | ||
from shelllogger import ShellLogger | ||
|
||
sl = ShellLogger("Hello ShellLogger", | ||
Path.cwd() / f"log_{Path(__file__).stem}") | ||
sl.print("This example demonstrates logging information both to the HTML log " | ||
"file and to the console simultaneously.") | ||
sl.log("Greet everyone to make them feel welcome.", "echo 'Hello World'", | ||
live_stdout=True, live_stderr=True) | ||
sl.log("Tell everyone who you are, but from a different directory.", "whoami", | ||
cwd=Path.cwd().parent, live_stdout=True, live_stderr=True) | ||
sl.finalize() | ||
print(f"Open {sl.html_file} to view the log.") |
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/usr/bin/env python3 | ||
|
||
from pathlib import Path | ||
from shelllogger import ShellLogger | ||
|
||
sl = ShellLogger("Hello ShellLogger", | ||
Path.cwd() / f"log_{Path(__file__).stem}") | ||
sl.print("This example demonstrates logging information solely to the HTML " | ||
"log file, while collecting CPU, memory, and disk statistics at the " | ||
"same time.") | ||
sl.log("Greet everyone to make them feel welcome.", "echo 'Hello World'", | ||
measure=["cpu", "memory", "disk"]) | ||
sl.log("Tell everyone who you are, but from a different directory.", "whoami", | ||
cwd=Path.cwd().parent, measure=["cpu", "memory", "disk"]) | ||
sl.finalize() | ||
print(f"Open {sl.html_file} to view the log.") |