maleo-foundation 0.0.41__py3-none-any.whl → 0.0.43__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,33 @@
1
+ from typing import Dict
2
+ from maleo_foundation.enums import BaseEnums
3
+ from maleo_foundation.types import BaseTypes
4
+ from maleo_foundation.utils.logger import BaseLogger
5
+
6
+ class ClientLoggingManager:
7
+ _loggers:Dict[type, BaseLogger] = {}
8
+
9
+ @classmethod
10
+ def initialize(
11
+ cls,
12
+ base_dir:str,
13
+ client_name:str,
14
+ service_name:BaseTypes.OptionalString = None,
15
+ level:BaseEnums.LoggerLevel = BaseEnums.LoggerLevel.INFO
16
+ ) -> BaseLogger:
17
+ """Initialize client logger if not already initialized."""
18
+ if cls not in cls._loggers:
19
+ cls._loggers[cls] = BaseLogger(
20
+ base_dir=base_dir,
21
+ type=BaseEnums.LoggerType.CLIENT,
22
+ service_name=service_name,
23
+ client_name=client_name,
24
+ level=level
25
+ )
26
+ return cls._loggers[cls]
27
+
28
+ @classmethod
29
+ def get(cls) -> BaseLogger:
30
+ """Return client logger (if exist) or raise Runtime Error"""
31
+ if cls not in cls._loggers:
32
+ raise RuntimeError("Logger has not been initialized. Call 'initialize' first.")
33
+ return cls._loggers[cls]
@@ -1,15 +1,15 @@
1
1
  from __future__ import annotations
2
2
  from datetime import date, datetime, timedelta, timezone
3
3
  from pydantic import BaseModel, Field, model_validator, field_serializer, FieldSerializationInfo
4
- from typing import Optional, Any
4
+ from typing import Any
5
5
  from uuid import UUID
6
6
  from maleo_foundation.constants import REFRESH_TOKEN_DURATION_DAYS, ACCESS_TOKEN_DURATION_MINUTES
7
7
  from maleo_foundation.enums import BaseEnums
8
8
  from maleo_foundation.types import BaseTypes
9
9
 
10
10
  class BaseGeneralSchemas:
11
- class IDs(BaseModel):
12
- ids:BaseTypes.OptionalListOfIntegers = Field(None, description="Specific IDs")
11
+ class Ids(BaseModel):
12
+ ids:BaseTypes.OptionalListOfIntegers = Field(None, description="Specific Ids")
13
13
 
14
14
  class Search(BaseModel):
15
15
  search:BaseTypes.OptionalString = Field(None, description="Search parameter string.")
@@ -11,7 +11,7 @@ class BaseClientParametersTransfers:
11
11
  BaseGeneralSchemas.Search,
12
12
  BaseGeneralSchemas.Statuses,
13
13
  BaseParameterSchemas.DateFilters,
14
- BaseGeneralSchemas.IDs,
14
+ BaseGeneralSchemas.Ids,
15
15
  ):
16
16
  pass
17
17
 
@@ -13,7 +13,7 @@ class BaseServiceParametersTransfers:
13
13
  BaseGeneralSchemas.Search,
14
14
  BaseGeneralSchemas.Statuses,
15
15
  BaseParameterSchemas.Filters,
16
- BaseGeneralSchemas.IDs
16
+ BaseGeneralSchemas.Ids
17
17
  ): pass
18
18
 
19
19
  class GetUnpaginatedMultiple(
@@ -62,12 +62,16 @@ class BaseLogger(logging.Logger):
62
62
  self.warning(f"Failed to initialize Google Cloud Logging: {str(e)}")
63
63
 
64
64
  #* Define log directory
65
- log_dir = os.path.join(base_dir, f"logs/{type}")
66
- os.makedirs(log_dir, exist_ok=True)
65
+ if type == BaseEnums.LoggerType.CLIENT:
66
+ log_dir = f"logs/{type}/{client_name}"
67
+ else:
68
+ log_dir = f"logs/{type}"
69
+ full_log_dir = os.path.join(base_dir, log_dir)
70
+ os.makedirs(full_log_dir, exist_ok=True)
67
71
 
68
72
  #* Generate timestamped filename
69
73
  timestamp = datetime.now().strftime("%Y-%m-%d_%H-%M-%S")
70
- log_filename = os.path.join(log_dir, f"{timestamp}.log")
74
+ log_filename = os.path.join(full_log_dir, f"{timestamp}.log")
71
75
 
72
76
  #* File handler
73
77
  file_handler = logging.FileHandler(log_filename, mode="a")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: maleo_foundation
3
- Version: 0.0.41
3
+ Version: 0.0.43
4
4
  Summary: Foundation package for Maleo
5
5
  Author-email: Agra Bima Yuda <agra@nexmedis.com>
6
6
  License: MIT
@@ -6,6 +6,7 @@ maleo_foundation/extended_types.py,sha256=pIKt-_9tby4rmune3fmWcCW_mohaNRh_1lywBm
6
6
  maleo_foundation/query.py,sha256=qJV9-QX5bphsmijXf4I8cuwMnqlJkm0dxypJ9Qz1eS8,3850
7
7
  maleo_foundation/types.py,sha256=D_EtYK-sNeELSbc-ngX65iuQCRhZQB4TtV73P6Gl76o,1206
8
8
  maleo_foundation/clients/__init__.py,sha256=W8vydJYeDEi6gdmOZSBFSSDsfZJtb8C05CHErZgsZ30,188
9
+ maleo_foundation/clients/logging.py,sha256=JaAYfLkci97bTb6Wt5YO1uxQK5afIMuR8kin0q5rlIM,1145
9
10
  maleo_foundation/clients/general/__init__.py,sha256=l9eQrBeLW4aXtGU5aK3i6fD-msVR4526W7D9V8WCXIg,91
10
11
  maleo_foundation/clients/general/http.py,sha256=Awvs470hgdhZSZW_uoIFJGcJ5hcfDEIX0A2yUaP9UCA,1353
11
12
  maleo_foundation/clients/google/__init__.py,sha256=1uv6nF9QbATsSAcMimQOT7Y-eBljjDunBojNX6oAtS8,90
@@ -27,14 +28,14 @@ maleo_foundation/middlewares/cors.py,sha256=9uvBvY2N6Vxa9RP_YtESxcWo6Doi6uS0lzAG
27
28
  maleo_foundation/models/__init__.py,sha256=AaKehO7c1HyKhoTGRmNHDddSeBXkW-_YNrpOGBu8Ms8,246
28
29
  maleo_foundation/models/responses.py,sha256=ePz7yNEYVCNxxrQlj_dnWXspv1HAnBAHCQfyaaqTHdo,4541
29
30
  maleo_foundation/models/schemas/__init__.py,sha256=Xj8Ahsqyra-fmEaVcGPok5GOOsPQlKcknHYMvbjvENA,277
30
- maleo_foundation/models/schemas/general.py,sha256=djYzD-Dl4Gy0cFUde-ijuap5xmyVt232bJkazxKkuow,6666
31
+ maleo_foundation/models/schemas/general.py,sha256=aZKlYvzk2vvfkAXCfZzLkNm0hULW1f80RmwqYJ9mLN4,6656
31
32
  maleo_foundation/models/schemas/parameter.py,sha256=K47z2NzmTEhUiOfRiRLyRPXoQurbWsKBL7ObXAxIWRY,2100
32
33
  maleo_foundation/models/schemas/result.py,sha256=V3dljS2AdtWW4Pf8YsnQuiCylN1bZtEY1AtYC7okWuI,1747
33
34
  maleo_foundation/models/transfers/__init__.py,sha256=B8oCZHE3NTsrJ_rviSXaDsuc-gc25jpjuhJO40lpQiE,222
34
35
  maleo_foundation/models/transfers/parameters/__init__.py,sha256=oKW4RPIEISISRjsJzD8lsCGY1HhZRTzshPpWHcJu86k,353
35
- maleo_foundation/models/transfers/parameters/client.py,sha256=GjRYMDO9I0ZEfFPFJTn1CIFHYX1tvEF6kY5olD2xqR0,4059
36
+ maleo_foundation/models/transfers/parameters/client.py,sha256=tn_Hwa-k-Utp5rODe7GylqZB8djIKKupgkUFscYCyLc,4059
36
37
  maleo_foundation/models/transfers/parameters/general.py,sha256=HLBS4nUYSrqftES2x43tzlAcDnscuH9OtM1X-Ym2Dto,530
37
- maleo_foundation/models/transfers/parameters/service.py,sha256=rSsHNIcroyGNPk4-aKSML7W0tGk_d1d-wmpou9HohTw,6757
38
+ maleo_foundation/models/transfers/parameters/service.py,sha256=d7Xy_R-DtLBRozyD6r8YnTiuKlE3sb9HMDCCq9WmUbY,6757
38
39
  maleo_foundation/models/transfers/results/__init__.py,sha256=0_8uJ1IQW87RZ4nIxzWkQVi3Fxb7B8myZTngXfoxgNc,241
39
40
  maleo_foundation/models/transfers/results/client/__init__.py,sha256=xBRuY0NUIPpQEGQ2qoBnqLZGX4W1YSrQ0VnDf5OYJBo,290
40
41
  maleo_foundation/models/transfers/results/client/service.py,sha256=TO_U53vmUEnFWiiyuu33ao3BUidt6KFxvk3GC9uo8JE,1108
@@ -47,10 +48,10 @@ maleo_foundation/models/transfers/results/service/controllers/__init__.py,sha256
47
48
  maleo_foundation/models/transfers/results/service/controllers/rest.py,sha256=wCuFyOTQkuBs2cqjPsWnPy0XIsCfMqGByhrSy57qp7Y,1107
48
49
  maleo_foundation/utils/__init__.py,sha256=tfgaHZI2PDgxEVSQztfnDMN5S6L5Y4FcK5v_Wkf5snE,245
49
50
  maleo_foundation/utils/exceptions.py,sha256=mcvBwHm6uWpVQkPtO1T2j-GaTYEiyPOeGxiDL9-sjNA,3639
50
- maleo_foundation/utils/logger.py,sha256=rfViHIMN6p9LeyH_fU_PiWvGuhHcivgk9zRQuXyw6ik,3180
51
+ maleo_foundation/utils/logger.py,sha256=sK95UC5jLKKuAV8lu8pFnoQfLRB0nPtCbmAC5CJLgO8,3338
51
52
  maleo_foundation/utils/formatter/__init__.py,sha256=iKf5YCbEdg1qKnFHyKqqcQbqAqEeRUf8mhI3v3dQoj8,78
52
53
  maleo_foundation/utils/formatter/case.py,sha256=TmvvlfzGdC_omMTB5vAa40TZBxQ3hnr-SYeo0M52Rlg,1352
53
- maleo_foundation-0.0.41.dist-info/METADATA,sha256=sMX6yNYfAGGFalLxQj-MmV82Vesp_HPGa6fX7EZnCcA,3160
54
- maleo_foundation-0.0.41.dist-info/WHEEL,sha256=lTU6B6eIfYoiQJTZNc-fyaR6BpL6ehTzU3xGYxn2n8k,91
55
- maleo_foundation-0.0.41.dist-info/top_level.txt,sha256=_iBos3F_bhEOdjOnzeiEYSrCucasc810xXtLBXI8cQc,17
56
- maleo_foundation-0.0.41.dist-info/RECORD,,
54
+ maleo_foundation-0.0.43.dist-info/METADATA,sha256=zNdA3XLw-6sE_yfuTmedt4IxTp2PTqSQN2SH8I6lKIk,3160
55
+ maleo_foundation-0.0.43.dist-info/WHEEL,sha256=pxyMxgL8-pra_rKaQ4drOZAegBVuX-G_4nRHjjgWbmo,91
56
+ maleo_foundation-0.0.43.dist-info/top_level.txt,sha256=_iBos3F_bhEOdjOnzeiEYSrCucasc810xXtLBXI8cQc,17
57
+ maleo_foundation-0.0.43.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (78.1.1)
2
+ Generator: setuptools (79.0.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5