Structured log example should contain example usage of set_default_logger, get_default_logger

RESOLVED FIXED in mozilla36

Status

defect
RESOLVED FIXED
5 years ago
5 years ago

People

(Reporter: wlach, Assigned: wlach)

Tracking

unspecified
mozilla36
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment, 1 obsolete attachment)

We're encouraging the use of this method, so let's update the example to match. This will make it easier for people to write new code that does the right thing.
Comment on attachment 8521597 [details] [diff] [review]
Make example program use get/set default logger method

Review of attachment 8521597 [details] [diff] [review]:
-----------------------------------------------------------------

::: testing/mozbase/docs/_static/structured_example.py
@@ +81,4 @@
>      args = parser.parse_args()
>  
>      logger = commandline.setup_logging("structured-example", args, {"raw": sys.stdout})
> +    set_default_logger(logger)

setup_logging already calls set_default_logger, so this example is misleading.
Attachment #8521597 - Flags: review?(james) → review-
Oops, I didn't know that. Updated the example as well as the main documentation to make things a bit more clear (also made links work a bit better for jumping around)
Attachment #8521597 - Attachment is obsolete: true
Attachment #8522474 - Flags: review?(james)
Comment on attachment 8522474 [details] [diff] [review]
Update example to not call set_default_logger, update documentation to be more clear

Review of attachment 8522474 [details] [diff] [review]:
-----------------------------------------------------------------

::: testing/mozbase/mozlog/mozlog/structured/commandline.py
@@ +124,4 @@
>      Configure a structuredlogger based on command line arguments.
>  
>      The created structuredlogger will also be set as the default logger, and
> +    can be retrieved with :py:func:`~mozlog.structured.structuredlog.get_default_logger`.

I'm assuming this link works without testing it.
Attachment #8522474 - Flags: review?(james) → review+
(In reply to James Graham [:jgraham] from comment #4)
> Comment on attachment 8522474 [details] [diff] [review]
> Update example to not call set_default_logger, update documentation to be
> more clear
> 
> Review of attachment 8522474 [details] [diff] [review]:
> -----------------------------------------------------------------
> 
> ::: testing/mozbase/mozlog/mozlog/structured/commandline.py
> @@ +124,4 @@
> >      Configure a structuredlogger based on command line arguments.
> >  
> >      The created structuredlogger will also be set as the default logger, and
> > +    can be retrieved with :py:func:`~mozlog.structured.structuredlog.get_default_logger`.
> 
> I'm assuming this link works without testing it.

Yeah, the handy thing about this syntax is that it compresses down to "get_default_logger" in the documentation while still linking to the correct place.
https://hg.mozilla.org/mozilla-central/rev/01977e8f381b
Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla36
You need to log in before you can comment on or make changes to this bug.