Skip to content

Commit ba94a31

Browse files
authored
Capitals for logging levels
1 parent 3a83ac6 commit ba94a31

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

_episodes/08-defensive.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ so that it isn't lost when we finish our command line session.
409409
for handler in logging.root.handlers[:]:
410410
logging.root.removeHandler(handler)
411411
412-
logging.basicConfig(level=logging.debug, filename='log.txt'))
412+
logging.basicConfig(level=logging.DEBUG, filename='log.txt'))
413413
414414
rh_data = np.array([1.5, 20.4, 100.1, 76.3, 54.4])
415415
rh_max = rh_data.max()
@@ -420,7 +420,10 @@ logging.debug(f'The maximum relative humidity was {rh_max}%')
420420
(The for loop is needed to turn off the background logging the notebook does itself.
421421
It's not needed in a Python script.)
422422

423-
By setting the logging level to "debug",
423+
Notice that we've used capital `logging.DEBUG` (which is an integer value) to set the logging level,
424+
as opposed to the `logging.debug` function that is used for logging a message.
425+
426+
By setting the logging level to "DEBUG",
424427
our output "log.txt" file will now capture all logging information
425428
with a flag of 'debug' or higher - that is,
426429
all logging outputs will be written to our log file.
@@ -451,7 +454,7 @@ and set the logging configuration and add a `logging.info` command in the `main`
451454
def main(inargs):
452455
"""Run the program."""
453456
454-
logging.basicConfig(level=logging.debug, filename='log.txt')
457+
logging.basicConfig(level=logging.DEBUG, filename='log.txt')
455458
456459
...
457460
@@ -478,7 +481,7 @@ def main(inargs):
478481
> def main(inargs):
479482
> """Run the program."""
480483
>
481-
> logging.basicConfig(level=logging.debug, filename='log.txt')
484+
> logging.basicConfig(level=logging.DEBUG, filename='log.txt')
482485
>
483486
> dset = xr.open_dataset(inargs.pr_file)
484487
>
@@ -553,7 +556,7 @@ def main(inargs):
553556
> > ## Solution
554557
> >
555558
> > The basic configuration command at the top of the `main` function
556-
> > (`logging.basicConfig(level=logging.debug, filename='log.txt')`)
559+
> > (`logging.basicConfig(level=logging.DEBUG, filename='log.txt')`)
557560
> > needs to be replaced with the following:
558561
> >
559562
> > ~~~

0 commit comments

Comments
 (0)