Skip to content

Commit 22ceeaf

Browse files
Added modulewise logger
1 parent 45be42c commit 22ceeaf

14 files changed

+107
-79
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# CHANGELOG
22

3+
## _v2.0.0_
4+
5+
### **Date: 28-APRIL-2025**
6+
7+
- Custom logger support
8+
39
## _v1.11.2_
410

511
### **Date: 21-APRIL-2025**

contentstack/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
__title__ = 'contentstack-delivery-python'
2323
__author__ = 'contentstack'
2424
__status__ = 'debug'
25-
__version__ = 'v1.11.2'
25+
__version__ = 'v2.0.0'
2626
__endpoint__ = 'cdn.contentstack.io'
2727
__email__ = '[email protected]'
2828
__developer_email__ = '[email protected]'

contentstack/asset.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,10 @@
77
import logging
88
from urllib import parse
99

10-
log = logging.getLogger(__name__)
11-
12-
1310
class Asset:
1411
r"""`Asset` refer to all the media files (images, videos, PDFs, audio files, and so on)."""
1512

16-
def __init__(self, http_instance, uid=None):
13+
def __init__(self, http_instance, uid=None, logger=None):
1714
self.http_instance = http_instance
1815
self.asset_params = {}
1916
self.__uid = uid
@@ -22,6 +19,7 @@ def __init__(self, http_instance, uid=None):
2219
self.base_url = f'{self.http_instance.endpoint}/assets/{self.__uid}'
2320
if 'environment' in self.http_instance.headers:
2421
self.asset_params['environment'] = self.http_instance.headers['environment']
22+
self.logger = logger or logging.getLogger(__name__)
2523

2624
def environment(self, environment):
2725
r"""Provide the name of the environment if you wish to retrieve the assets published

contentstack/assetquery.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,20 @@
99
from contentstack.basequery import BaseQuery
1010
from contentstack.utility import Utils
1111

12-
log = logging.getLogger(__name__)
13-
14-
1512
class AssetQuery(BaseQuery):
1613
"""
1714
This call fetches the list of all the assets of a particular stack.
1815
"""
1916

20-
def __init__(self, http_instance):
17+
def __init__(self, http_instance, logger=None):
2118
super().__init__()
2219
self.http_instance = http_instance
2320
self.asset_query_params = {}
2421
self.base_url = f"{self.http_instance.endpoint}/assets"
2522
if "environment" in self.http_instance.headers:
2623
env = self.http_instance.headers["environment"]
2724
self.base_url = f"{self.base_url}?environment={env}"
25+
self.logger = logger or logging.getLogger(__name__)
2826

2927
def environment(self, environment):
3028
r"""Provide the name of the environment if you wish to retrieve the assets published

contentstack/basequery.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
import enum
22
import logging
33

4-
log = logging.getLogger(__name__)
5-
6-
74
class QueryOperation(enum.Enum):
85
"""
96
QueryOperation is enum that Provides Options to perform operation to query the result.
@@ -38,9 +35,10 @@ class BaseQuery:
3835
Common Query class works for Query As well as Asset
3936
"""
4037

41-
def __init__(self):
38+
def __init__(self, logger=None):
4239
self.parameters = {}
4340
self.query_params = {}
41+
self.logger = logger or logging.getLogger(__name__)
4442

4543
def where(self, field_uid: str, query_operation: QueryOperation, fields=None):
4644
"""

contentstack/contenttype.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@
1414
from contentstack.entry import Entry
1515
from contentstack.query import Query
1616

17-
log = logging.getLogger(__name__)
18-
19-
2017
class ContentType:
2118
"""
2219
Content type defines the structure or schema of a page or a
@@ -26,10 +23,11 @@ class ContentType:
2623
content type.
2724
"""
2825

29-
def __init__(self, http_instance, content_type_uid):
26+
def __init__(self, http_instance, content_type_uid, logger=None):
3027
self.http_instance = http_instance
3128
self.__content_type_uid = content_type_uid
3229
self.local_param = {}
30+
self.logger = logger or logging.getLogger(__name__)
3331

3432
def entry(self, entry_uid: str):
3533
r"""

contentstack/entry.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@
99
from contentstack.deep_merge_lp import DeepMergeMixin
1010
from contentstack.entryqueryable import EntryQueryable
1111

12-
log = logging.getLogger(__name__)
13-
14-
1512
class Entry(EntryQueryable):
1613
"""
1714
An entry is the actual piece of content that you want to publish.
@@ -23,14 +20,15 @@ class Entry(EntryQueryable):
2320
locale={locale_code}
2421
"""
2522

26-
def __init__(self, http_instance, content_type_uid, entry_uid):
23+
def __init__(self, http_instance, content_type_uid, entry_uid, logger=None):
2724
super().__init__()
2825
EntryQueryable.__init__(self)
2926
self.entry_param = {}
3027
self.http_instance = http_instance
3128
self.content_type_id = content_type_uid
3229
self.entry_uid = entry_uid
3330
self.base_url = self.__get_base_url()
31+
self.logger = logger or logging.getLogger(__name__)
3432

3533
def environment(self, environment):
3634
"""

contentstack/entryqueryable.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,14 @@
44
"""
55
import logging
66

7-
log = logging.getLogger(__name__)
8-
9-
107
class EntryQueryable:
118
"""
129
This class is base class for the Entry and Query class that shares common functions
1310
"""
1411

15-
def __init__(self):
12+
def __init__(self, logger=None):
1613
self.entry_queryable_param = {}
14+
self.logger = logger or logging.getLogger(__name__)
1715

1816
def locale(self, locale: str):
1917
"""

contentstack/https_connection.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@
99
import contentstack
1010
from contentstack.controller import get_request
1111

12-
log = logging.getLogger(__name__)
13-
14-
1512
def __get_os_platform():
1613
os_platform = platform.system()
1714
if os_platform == 'Darwin':

contentstack/image_transform.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,14 @@
88

99
import logging
1010

11-
log = logging.getLogger(__name__)
12-
1311

1412
class ImageTransform: # pylint: disable=too-few-public-methods
1513
"""
1614
The Image Delivery API is used to retrieve, manipulate and/or convert image
1715
files
1816
"""
1917

20-
def __init__(self, http_instance, image_url, **kwargs):
18+
def __init__(self, http_instance, image_url, logger=None, **kwargs):
2119
"""
2220
creates instance of the ImageTransform class
2321
:param httpInstance: instance of HttpsConnection
@@ -35,6 +33,7 @@ def __init__(self, http_instance, image_url, **kwargs):
3533
self.http_instance = http_instance
3634
self.image_url = image_url
3735
self.image_params = kwargs
36+
self.logger = logger or logging.getLogger(__name__)
3837

3938
def get_url(self):
4039
"""

0 commit comments

Comments
 (0)