Skip to content

Commit

Permalink
Add example for enabling logging
Browse files Browse the repository at this point in the history
  • Loading branch information
Yilmaz4 committed Jan 11, 2022
1 parent 1a7faf9 commit 4d4b06e
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions examples/enable_logging.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
from perspective import Client, Attributes

API_KEY = "AIzaSyA-yzvgANWE1STU9MTbTLrS3rj1956tVAs"

"""
+--------+-----------+
| Number | Level |
+--------+-----------+
| 50 | CRITICAL |
+--------+-----------+
| 40 | ERROR |
+--------+-----------+
| 30 | WARNING |
+--------+-----------+
| 20 | INFO |
+--------+-----------+
| 10 | DEBUG |
+--------+-----------+
| 0 | NOTSET |
+--------+-----------+
"""

# Set logging level to 20 (INFO) while creating the Client object
perspective = Client(token = API_KEY, logging_level=20)

# Modify logging level to 10 (DEBUG) which would show literally every logging message
perspective.logging_level = 10

# Modify logging level again to 0 (NOTSET) which would disable logging
perspective.logging_level = 0

response = perspective.analyze(text = "Never gonna give you up", attributes = Attributes.All, skip_on_lang=True, skip_on_unknown=False, return_raw=False)

print(response)

0 comments on commit 4d4b06e

Please sign in to comment.