Skip to content

Update debugging.md #474

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion docs/cheatsheet/debugging.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ Say you wrote a function to calculate the factorial of a number. In mathematics,
>>> def factorial(n):
... logging.debug('Start of factorial(%s)' % (n))
... total = 1
... for i in range(1, n + 1):
... for i in range(0, n + 1):
... total *= i
... logging.debug('i is ' + str(i) + ', total is ' + str(total))
... logging.debug('End of factorial(%s)' % (n))
Expand All @@ -159,6 +159,8 @@ Say you wrote a function to calculate the factorial of a number. In mathematics,
# 2015-05-23 16:20:12,684 - DEBUG - End of program
```

Using the log output, we can see that `for i in range(0, n + 1)` should have been `for i in range(1, n + 1)`.

## Logging Levels

Logging levels provide a way to categorize your log messages by importance. There are five logging levels, described in Table 10-1 from least to most important. Messages can be logged at each level using a different logging function.
Expand Down