Skip to content

Commit 23a4e85

Browse files
committed
rename decorator to secure_logger()
1 parent fc2884a commit 23a4e85

File tree

7 files changed

+17
-23
lines changed

7 files changed

+17
-23
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/)
66
and this project adheres to [Semantic Versioning](http://semver.org/).
77

8+
## [0.1.1] (2023-04-25)
9+
10+
- renamed to secure_logger
11+
812
## [0.1.0] (2023-04-14)
913

1014
- initial release

Makefile

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,6 @@
33
# -------------------------------------------------------------------------
44
.PHONY: build requirements deps-update deps-init
55

6-
django-server:
7-
./manage.py runserver 0.0.0.0:8000
8-
9-
django-shell:
10-
./manage.py shell_plus
11-
12-
13-
django-test:
14-
./manage.py test
15-
166
requirements:
177
pre-commit autoupdate
188
python -m pip install --upgrade pip wheel

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ pip install secure-logger
3131
## Usage
3232

3333
```python
34-
from secure_logger.decorators import app_logger
34+
from secure_logger.decorators import secure_logger
3535

3636
MY_SENSITIVE_KEYS = ["top-secret-password", "equally-secret-value",]
3737

3838
class TestClass(object):
3939

40-
@app_logger(sensitive_keys=MY_SENSITIVE_KEYS, indent=4)
40+
@secure_logger(sensitive_keys=MY_SENSITIVE_KEYS, indent=4)
4141
def test_2(self, test_dict, test_list):
4242
pass
4343

@@ -51,10 +51,10 @@ o = TestClass()
5151
o.test_2(test_dict=test_dict, test_list=test_list)
5252
```
5353

54-
Output
54+
Generates log entries of this style and form:
5555

5656
```log
57-
INFO:app_logger: __main__.TestClass().test_2() keyword args: {
57+
INFO:secure_logger: __main__.TestClass().test_2() keyword args: {
5858
"test_dict": {
5959
"insensitive_key": "you-can-see-me",
6060
"top-secret-password": "*** -- REDACTED -- ***",

__about__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
# Increment this version number to trigger a new release. See
99
# CHANGELOG.md for information on the versioning scheme.
10-
__version__ = "0.1.0"
10+
__version__ = "0.1.1"
1111

1212
# The app name will be used to define the name of the default plugin root and
1313
# plugin directory. To avoid conflicts between multiple locally-installed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ build-backend = "setuptools.build_meta:__legacy__"
2424
#------------------------------------------------------------------------------
2525
[project]
2626
name = "secure-logger"
27-
version = "0.1.0"
27+
version = "0.1.1"
2828
authors = [
2929
{ name="Lawrence McDaniel", email="[email protected]" }
3030
]

secure_logger/decorators.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
logger = logging.getLogger(__name__)
1313

1414

15-
def app_logger(sensitive_keys: list = DEFAULT_SENSITIVE_KEYS, indent: int = 4):
15+
def secure_logger(sensitive_keys: list = DEFAULT_SENSITIVE_KEYS, indent: int = 4):
1616
"""Top level decorator, for defining input parameters."""
1717

1818
def decorate(func):
@@ -23,7 +23,7 @@ def decorate(func):
2323
its positional arguments, and keyword pairs presented as a formatted dict.
2424
2525
Sample output:
26-
2022-07-08 19:40:51,085 INFO app_logger: courses.views.CourseListingView().get_queryset()
26+
2022-07-08 19:40:51,085 INFO secure_logger: courses.views.CourseListingView().get_queryset()
2727
"""
2828

2929
@wraps(func)
@@ -65,7 +65,7 @@ def wrapper(*args, **kwargs):
6565
kwargs_dict_repr += serialized_masked_dict(kwargs, sensitive_keys=sensitive_keys, indent=indent)
6666

6767
logger.info(
68-
"app_logger: {name_spec} {args} {kwargs}".format(
68+
"secure_logger: {name_spec} {args} {kwargs}".format(
6969
name_spec=name_spec,
7070
args=positional_args if len(positional_args) > 0 else "",
7171
kwargs=kwargs_dict_repr,

tests.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"""
77
import logging
88

9-
from secure_logger.decorators import app_logger
9+
from secure_logger.decorators import secure_logger
1010

1111
logging.basicConfig(level=logging.DEBUG)
1212

@@ -18,7 +18,7 @@
1818
]
1919

2020

21-
@app_logger(sensitive_keys=MY_SENSITIVE_KEYS, indent=4)
21+
@secure_logger(sensitive_keys=MY_SENSITIVE_KEYS, indent=4)
2222
def test_1(msg):
2323
"""Test 1: a simple module function."""
2424
print("test 1: " + msg) # noqa: T201
@@ -27,13 +27,13 @@ def test_1(msg):
2727
class TestClass(object):
2828
"""Test class method logging."""
2929

30-
@app_logger()
30+
@secure_logger()
3131
def test_2(self, test_dict, test_list):
3232
"""Test class input parameter as objects."""
3333
pass
3434

3535

36-
@app_logger()
36+
@secure_logger()
3737
class Test3:
3838
"""Test 3: decorate a class."""
3939

0 commit comments

Comments
 (0)