Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(logger): possibility to override debug mode's default logging me…
…chanism
- Loading branch information
1 parent
65c68db
commit 944d9de
Showing
6 changed files
with
115 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
> ⚠ This document _only_ reflects the responsible developers at HEXONET GmbH. For a list of MUCH-APPRECIATED CONTRIBUTORS -- people who helped developing and extending this library, applying patches, adding helpful comments | ||
and thus generally made it that much better, see [GitHub's list of contributors](https://github.com/hexonet/python-sdk/contributors). | ||
|
||
* [Anthony Schneider](//github.com/anthonyschn) - Original Implementation | ||
* [Kai Schwarz](//github.com/papakai) - Full Review | ||
* [Kai Schwarz](//github.com/papakai) - Development Lead |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
hexonet.apiconnector.customlogger | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
This module provides all necessary functionality for | ||
debug outputs | ||
:copyright: © 2020 by HEXONET GmbH. | ||
:license: MIT, see LICENSE for more details. | ||
""" | ||
|
||
from hexonet.apiconnector.logger import Logger | ||
import sys | ||
|
||
|
||
class CustomLogger(Logger, object): | ||
""" | ||
The Logger class covers all you need to cover debug outputs of the API communication. | ||
""" | ||
|
||
def __init__(self): | ||
""" | ||
constructor calling parent constructor | ||
""" | ||
super(CustomLogger, self).__init__() | ||
|
||
def log(self, post, r, error): | ||
""" | ||
output/log given data | ||
""" | ||
# | ||
# implement your own logic here | ||
# | ||
# print(r.getCommandPlain()) | ||
# print(post) | ||
# if error: | ||
# print("HTTP communication failed: %s" % (error), sys.stderr) | ||
# print(r.getPlain()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
hexonet.apiconnector.logger | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
This module provides all necessary functionality for | ||
debug outputs see the customlogger class on how to override this | ||
:copyright: © 2018 by HEXONET GmbH. | ||
:license: MIT, see LICENSE for more details. | ||
""" | ||
|
||
import sys | ||
|
||
|
||
class Logger(object): | ||
""" | ||
The Logger class covers all you need to cover debug outputs of the API communication. | ||
""" | ||
|
||
def log(self, post, r, error): | ||
""" | ||
output/log given data | ||
""" | ||
print(r.getCommandPlain()) | ||
print(post) | ||
if error: | ||
print("HTTP communication failed: %s" % (error), sys.stderr) | ||
print(r.getPlain()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters