-
Notifications
You must be signed in to change notification settings - Fork 1
added more description to logging and a python example #145
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
base: master
Are you sure you want to change the base?
Changes from 1 commit
9f878dd
4cdab8f
563fabf
47e53f4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -147,9 +147,17 @@ meanings): | |
| - critical - Something went wrong, but recovery is not possible | ||
|
|
||
| Severity increases from "trace" to "critical" such that "trace" is the least | ||
| important and "critical" is the most severe log statements. In practice, the | ||
| value of a computed result usually falls under debug or trace. There's at least | ||
| two ways to do that: | ||
| important and "critical" is the most severe log statements. This means that | ||
| all logging statements set as trace and below are enabled if the severity of | ||
| the logger is set to trace. If the logger is set to debug, all debug, info, | ||
| warn, error, and critical message logs are enabled, while trace message logs | ||
| are not. For completeness, info includes info, warn, error, critical, and | ||
| warn includes warn, error, critical, and error includes error and critical, | ||
| and critical only includes critical. | ||
|
||
|
|
||
|
|
||
| In practice, the value of a computed result usually falls under debug or | ||
| trace. There's at least two ways to do that: | ||
|
|
||
| .. tabs:: | ||
|
|
||
|
|
@@ -172,6 +180,43 @@ level has its own corresponding method. The second example shows how to use | |
| the more general ``log`` method. This particular overload of the ``log`` method | ||
| allows you to specify (at runtime if you like) the severity of the message. | ||
|
|
||
| ******************** | ||
| Python Example | ||
| ******************** | ||
|
||
|
|
||
| .. tabs:: | ||
|
|
||
| .. tab:: Python | ||
|
|
||
| .. code-block:: python | ||
|
|
||
| import parallelzone as pz | ||
|
|
||
| log = pz.runtime.RuntimeView().logger() | ||
| severity = pz.Logger.severity | ||
| severities = [severity.trace, severity.debug, severity.info, severity.warn, severity.error, severity.critical] | ||
|
|
||
| log.set_severity(severity.critical) | ||
|
|
||
| for level in severities: | ||
| log.log(level, "Hello") | ||
|
|
||
| # OUTPUT: | ||
| # [2025-05-06 11:29:54.722] [Rank 0] [critical] Hello | ||
|
|
||
| log.set_severity(severity.trace) | ||
|
|
||
| for level in severities: | ||
| log.log(level, "Hello") | ||
|
|
||
| # OUTPUT: | ||
| # [2025-05-06 11:33:05.203] [Rank 0] [trace] Hello | ||
| # [2025-05-06 11:33:05.203] [Rank 0] [debug] Hello | ||
| # [2025-05-06 11:33:05.203] [Rank 0] [info] Hello | ||
| # [2025-05-06 11:33:05.203] [Rank 0] [warning] Hello | ||
| # [2025-05-06 11:33:05.203] [Rank 0] [error] Hello | ||
| # [2025-05-06 11:33:05.203] [Rank 0] [critical] Hello | ||
|
|
||
|
||
| .. note:: | ||
|
|
||
| Notice that we did not discuss where the log message gets printed. This is | ||
|
|
||
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.