maleo-foundation 0.0.1__py3-none-any.whl → 0.0.2__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.
- maleo_foundation/__init__.py +0 -0
- maleo_foundation/clients/__init__.py +7 -0
- maleo_foundation/clients/general/__init__.py +4 -0
- maleo_foundation/clients/general/http.py +41 -0
- maleo_foundation/clients/google/__init__.py +4 -0
- maleo_foundation/clients/google/cloud/__init__.py +8 -0
- maleo_foundation/clients/google/cloud/logging.py +45 -0
- maleo_foundation/clients/google/cloud/secret.py +92 -0
- maleo_foundation/clients/google/cloud/storage.py +77 -0
- maleo_foundation/constants.py +8 -0
- maleo_foundation/controller.py +50 -0
- maleo_foundation/db/__init__.py +3 -0
- maleo_foundation/db/database.py +41 -0
- maleo_foundation/db/engine.py +40 -0
- maleo_foundation/db/session.py +64 -0
- maleo_foundation/models/__init__.py +13 -0
- maleo_foundation/models/enums.py +66 -0
- maleo_foundation/models/responses.py +99 -0
- maleo_foundation/models/schemas/__init__.py +9 -0
- maleo_foundation/models/schemas/general.py +105 -0
- maleo_foundation/models/schemas/parameter.py +16 -0
- maleo_foundation/models/schemas/result.py +89 -0
- maleo_foundation/models/transfers/__init__.py +7 -0
- maleo_foundation/models/transfers/parameters/__init__.py +9 -0
- maleo_foundation/models/transfers/parameters/client.py +65 -0
- maleo_foundation/models/transfers/parameters/general.py +13 -0
- maleo_foundation/models/transfers/parameters/service.py +121 -0
- maleo_foundation/models/transfers/results/__init__.py +7 -0
- maleo_foundation/models/transfers/results/client/__init__.py +7 -0
- maleo_foundation/models/transfers/results/client/controllers/__init__.py +5 -0
- maleo_foundation/models/transfers/results/client/controllers/http.py +35 -0
- maleo_foundation/models/transfers/results/client/service.py +27 -0
- maleo_foundation/models/transfers/results/service/__init__.py +9 -0
- maleo_foundation/models/transfers/results/service/controllers/__init__.py +5 -0
- maleo_foundation/models/transfers/results/service/controllers/rest.py +22 -0
- maleo_foundation/models/transfers/results/service/general.py +38 -0
- maleo_foundation/models/transfers/results/service/query.py +42 -0
- maleo_foundation/models/types/__init__.py +9 -0
- maleo_foundation/models/types/client.py +40 -0
- maleo_foundation/models/types/query.py +40 -0
- maleo_foundation/models/types/service.py +40 -0
- maleo_foundation/utils/__init__.py +9 -0
- maleo_foundation/utils/exceptions.py +74 -0
- maleo_foundation/utils/formatter/__init__.py +4 -0
- maleo_foundation/utils/formatter/case.py +37 -0
- maleo_foundation/utils/logger.py +68 -0
- {maleo_foundation-0.0.1.dist-info → maleo_foundation-0.0.2.dist-info}/METADATA +1 -1
- maleo_foundation-0.0.2.dist-info/RECORD +50 -0
- maleo_foundation-0.0.2.dist-info/top_level.txt +1 -0
- maleo_foundation-0.0.1.dist-info/RECORD +0 -4
- maleo_foundation-0.0.1.dist-info/top_level.txt +0 -1
- {maleo_foundation-0.0.1.dist-info → maleo_foundation-0.0.2.dist-info}/WHEEL +0 -0
@@ -0,0 +1,22 @@
|
|
1
|
+
from __future__ import annotations
|
2
|
+
from fastapi import status, Response
|
3
|
+
from typing import Any
|
4
|
+
from pydantic import BaseModel, Field, model_validator
|
5
|
+
from maleo_foundation.models.enums import BaseEnums
|
6
|
+
|
7
|
+
class BaseServiceRESTControllerResults(BaseModel):
|
8
|
+
success:bool = Field(..., description="REST Controller's success status")
|
9
|
+
response_type:BaseEnums.RESTControllerResponseType = Field(BaseEnums.RESTControllerResponseType.JSON, description="REST Controller's response class")
|
10
|
+
content:Any = Field(..., description="REST Controller's response content")
|
11
|
+
status_code:int = Field(status.HTTP_200_OK, description="REST Controller's response status code")
|
12
|
+
response:Response = Field(Response(), description="REST Controller's Response")
|
13
|
+
|
14
|
+
class Config:
|
15
|
+
arbitrary_types_allowed=True
|
16
|
+
|
17
|
+
@model_validator(mode="after")
|
18
|
+
def process_response(self):
|
19
|
+
"""Dynamically creates a response based on response_type."""
|
20
|
+
response_cls = self.response_type.get_response_type()
|
21
|
+
self.response = response_cls(content=self.content, status_code=self.status_code)
|
22
|
+
return self
|
@@ -0,0 +1,38 @@
|
|
1
|
+
from __future__ import annotations
|
2
|
+
from pydantic import model_validator
|
3
|
+
from maleo_foundation.models.schemas.general import BaseGeneralSchemas
|
4
|
+
from maleo_foundation.models.schemas.result import BaseResultSchemas
|
5
|
+
|
6
|
+
class BaseServiceGeneralResultsTransfers:
|
7
|
+
class Fail(BaseResultSchemas.Fail): pass
|
8
|
+
|
9
|
+
class NoData(BaseResultSchemas.NoData): pass
|
10
|
+
|
11
|
+
class SingleData(BaseResultSchemas.SingleData): pass
|
12
|
+
|
13
|
+
class UnpaginatedMultipleData(BaseResultSchemas.UnpaginatedMultipleData): pass
|
14
|
+
|
15
|
+
class PaginatedMultipleData(BaseResultSchemas.PaginatedMultipleData):
|
16
|
+
@model_validator(mode="before")
|
17
|
+
@classmethod
|
18
|
+
def calculate_pagination(cls, values: dict) -> dict:
|
19
|
+
"""Calculates pagination metadata before validation."""
|
20
|
+
total_data = values.get("total_data", 0)
|
21
|
+
data = values.get("data", [])
|
22
|
+
|
23
|
+
#* Get pagination values from inherited SimplePagination
|
24
|
+
page = values.get("page", 1)
|
25
|
+
limit = values.get("limit", 10)
|
26
|
+
|
27
|
+
#* Calculate total pages
|
28
|
+
total_pages = (total_data // limit) + (1 if total_data % limit > 0 else 0)
|
29
|
+
|
30
|
+
#* Assign computed pagination object before validation
|
31
|
+
values["pagination"] = BaseGeneralSchemas.ExtendedPagination(
|
32
|
+
page=page,
|
33
|
+
limit=limit,
|
34
|
+
data_count=len(data),
|
35
|
+
total_data=total_data,
|
36
|
+
total_pages=total_pages
|
37
|
+
)
|
38
|
+
return values
|
@@ -0,0 +1,42 @@
|
|
1
|
+
from __future__ import annotations
|
2
|
+
from pydantic import model_validator
|
3
|
+
from maleo_foundation.models.schemas.general import BaseGeneralSchemas
|
4
|
+
from maleo_foundation.models.schemas.result import BaseResultSchemas
|
5
|
+
|
6
|
+
class BaseServiceQueryResultsTransfers:
|
7
|
+
class Fail(BaseResultSchemas.Fail): pass
|
8
|
+
|
9
|
+
class NoData(BaseResultSchemas.NoData): pass
|
10
|
+
|
11
|
+
class SingleData(BaseResultSchemas.SingleData):
|
12
|
+
data:BaseResultSchemas.Row
|
13
|
+
|
14
|
+
class UnpaginatedMultipleData(BaseResultSchemas.UnpaginatedMultipleData):
|
15
|
+
data:list[BaseResultSchemas.Row]
|
16
|
+
|
17
|
+
class PaginatedMultipleData(BaseResultSchemas.PaginatedMultipleData):
|
18
|
+
data:list[BaseResultSchemas.Row]
|
19
|
+
|
20
|
+
@model_validator(mode="before")
|
21
|
+
@classmethod
|
22
|
+
def calculate_pagination(cls, values: dict) -> dict:
|
23
|
+
"""Calculates pagination metadata before validation."""
|
24
|
+
total_data = values.get("total_data", 0)
|
25
|
+
data = values.get("data", [])
|
26
|
+
|
27
|
+
#* Get pagination values from inherited SimplePagination
|
28
|
+
page = values.get("page", 1)
|
29
|
+
limit = values.get("limit", 10)
|
30
|
+
|
31
|
+
#* Calculate total pages
|
32
|
+
total_pages = (total_data // limit) + (1 if total_data % limit > 0 else 0)
|
33
|
+
|
34
|
+
#* Assign computed pagination object before validation
|
35
|
+
values["pagination"] = BaseGeneralSchemas.ExtendedPagination(
|
36
|
+
page=page,
|
37
|
+
limit=limit,
|
38
|
+
data_count=len(data),
|
39
|
+
total_data=total_data,
|
40
|
+
total_pages=total_pages
|
41
|
+
)
|
42
|
+
return values
|
@@ -0,0 +1,40 @@
|
|
1
|
+
from typing import Awaitable, Callable, Union
|
2
|
+
from maleo_foundation.models.transfers.parameters.general import BaseGeneralParametersTransfers
|
3
|
+
from maleo_foundation.models.transfers.parameters.client import BaseClientParametersTransfers
|
4
|
+
from maleo_foundation.models.transfers.results.client.service import BaseClientServiceResultsTransfers
|
5
|
+
|
6
|
+
class BaseClientTypes:
|
7
|
+
GetMultipleParameter = BaseClientParametersTransfers.GetMultiple
|
8
|
+
|
9
|
+
GetMultipleResult = Union[
|
10
|
+
BaseClientServiceResultsTransfers.Fail,
|
11
|
+
BaseClientServiceResultsTransfers.NoData,
|
12
|
+
BaseClientServiceResultsTransfers.UnpaginatedMultipleData,
|
13
|
+
BaseClientServiceResultsTransfers.PaginatedMultipleData
|
14
|
+
]
|
15
|
+
|
16
|
+
SyncGetMultipleFunction = Callable[[GetMultipleParameter], GetMultipleResult]
|
17
|
+
|
18
|
+
AsyncGetMultipleFunction = Callable[[GetMultipleParameter], Awaitable[GetMultipleResult]]
|
19
|
+
|
20
|
+
GetSingleParameter = BaseGeneralParametersTransfers.GetSingle
|
21
|
+
|
22
|
+
GetSingleResult = Union[
|
23
|
+
BaseClientServiceResultsTransfers.Fail,
|
24
|
+
BaseClientServiceResultsTransfers.NoData,
|
25
|
+
BaseClientServiceResultsTransfers.SingleData
|
26
|
+
]
|
27
|
+
|
28
|
+
SyncGetSingleFunction = Callable[[GetSingleParameter], GetSingleResult]
|
29
|
+
|
30
|
+
AsyncGetSingleFunction = Callable[[GetSingleParameter], Awaitable[GetSingleResult]]
|
31
|
+
|
32
|
+
CreateOrUpdateResult = Union[
|
33
|
+
BaseClientServiceResultsTransfers.Fail,
|
34
|
+
BaseClientServiceResultsTransfers.SingleData
|
35
|
+
]
|
36
|
+
|
37
|
+
StatusUpdateResult = Union[
|
38
|
+
BaseClientServiceResultsTransfers.Fail,
|
39
|
+
BaseClientServiceResultsTransfers.SingleData
|
40
|
+
]
|
@@ -0,0 +1,40 @@
|
|
1
|
+
from typing import Awaitable, Callable, Union
|
2
|
+
from maleo_foundation.models.transfers.parameters.general import BaseGeneralParametersTransfers
|
3
|
+
from maleo_foundation.models.transfers.parameters.service import BaseServiceParametersTransfers
|
4
|
+
from maleo_foundation.models.transfers.results.service.query import BaseServiceQueryResultsTransfers
|
5
|
+
|
6
|
+
class BaseQueryTypes:
|
7
|
+
GetMultipleParameter = BaseServiceParametersTransfers.GetMultiple
|
8
|
+
|
9
|
+
GetMultipleResult = Union[
|
10
|
+
BaseServiceQueryResultsTransfers.Fail,
|
11
|
+
BaseServiceQueryResultsTransfers.NoData,
|
12
|
+
BaseServiceQueryResultsTransfers.UnpaginatedMultipleData,
|
13
|
+
BaseServiceQueryResultsTransfers.PaginatedMultipleData
|
14
|
+
]
|
15
|
+
|
16
|
+
SyncGetMultipleFunction = Callable[[GetMultipleParameter], GetMultipleResult]
|
17
|
+
|
18
|
+
AsyncGetMultipleFunction = Callable[[GetMultipleParameter], Awaitable[GetMultipleResult]]
|
19
|
+
|
20
|
+
GetSingleParameter = BaseGeneralParametersTransfers.GetSingle
|
21
|
+
|
22
|
+
GetSingleResult = Union[
|
23
|
+
BaseServiceQueryResultsTransfers.Fail,
|
24
|
+
BaseServiceQueryResultsTransfers.NoData,
|
25
|
+
BaseServiceQueryResultsTransfers.SingleData
|
26
|
+
]
|
27
|
+
|
28
|
+
SyncGetSingleFunction = Callable[[GetSingleParameter], GetSingleResult]
|
29
|
+
|
30
|
+
AsyncGetSingleFunction = Callable[[GetSingleParameter], Awaitable[GetSingleResult]]
|
31
|
+
|
32
|
+
CreateOrUpdateResult = Union[
|
33
|
+
BaseServiceQueryResultsTransfers.Fail,
|
34
|
+
BaseServiceQueryResultsTransfers.SingleData
|
35
|
+
]
|
36
|
+
|
37
|
+
StatusUpdateResult = Union[
|
38
|
+
BaseServiceQueryResultsTransfers.Fail,
|
39
|
+
BaseServiceQueryResultsTransfers.SingleData
|
40
|
+
]
|
@@ -0,0 +1,40 @@
|
|
1
|
+
from typing import Awaitable, Callable, Union
|
2
|
+
from maleo_foundation.models.transfers.parameters.general import BaseGeneralParametersTransfers
|
3
|
+
from maleo_foundation.models.transfers.parameters.service import BaseServiceParametersTransfers
|
4
|
+
from maleo_foundation.models.transfers.results.service.general import BaseServiceGeneralResultsTransfers
|
5
|
+
|
6
|
+
class BaseServiceTypes:
|
7
|
+
GetMultipleParameter = BaseServiceParametersTransfers.GetMultiple
|
8
|
+
|
9
|
+
GetMultipleResult = Union[
|
10
|
+
BaseServiceGeneralResultsTransfers.Fail,
|
11
|
+
BaseServiceGeneralResultsTransfers.NoData,
|
12
|
+
BaseServiceGeneralResultsTransfers.UnpaginatedMultipleData,
|
13
|
+
BaseServiceGeneralResultsTransfers.PaginatedMultipleData
|
14
|
+
]
|
15
|
+
|
16
|
+
SyncGetMultipleFunction = Callable[[GetMultipleParameter], GetMultipleResult]
|
17
|
+
|
18
|
+
AsyncGetMultipleFunction = Callable[[GetMultipleParameter], Awaitable[GetMultipleResult]]
|
19
|
+
|
20
|
+
GetSingleParameter = BaseGeneralParametersTransfers.GetSingle
|
21
|
+
|
22
|
+
GetSingleResult = Union[
|
23
|
+
BaseServiceGeneralResultsTransfers.Fail,
|
24
|
+
BaseServiceGeneralResultsTransfers.NoData,
|
25
|
+
BaseServiceGeneralResultsTransfers.SingleData
|
26
|
+
]
|
27
|
+
|
28
|
+
SyncGetSingleFunction = Callable[[GetSingleParameter], GetSingleResult]
|
29
|
+
|
30
|
+
AsyncGetSingleFunction = Callable[[GetSingleParameter], Awaitable[GetSingleResult]]
|
31
|
+
|
32
|
+
CreateOrUpdateResult = Union[
|
33
|
+
BaseServiceGeneralResultsTransfers.Fail,
|
34
|
+
BaseServiceGeneralResultsTransfers.SingleData
|
35
|
+
]
|
36
|
+
|
37
|
+
StatusUpdateResult = Union[
|
38
|
+
BaseServiceGeneralResultsTransfers.Fail,
|
39
|
+
BaseServiceGeneralResultsTransfers.SingleData
|
40
|
+
]
|
@@ -0,0 +1,74 @@
|
|
1
|
+
from fastapi import Request, status
|
2
|
+
from fastapi.exceptions import RequestValidationError
|
3
|
+
from fastapi.responses import JSONResponse
|
4
|
+
from functools import wraps
|
5
|
+
from starlette.exceptions import HTTPException as StarletteHTTPException
|
6
|
+
from sqlalchemy.exc import SQLAlchemyError
|
7
|
+
from maleo_foundation.models.responses import BaseResponses
|
8
|
+
from maleo_foundation.models.transfers.results.service.general import BaseServiceGeneralResultsTransfers
|
9
|
+
from maleo_foundation.models.transfers.results.service.query import BaseServiceQueryResultsTransfers
|
10
|
+
from maleo_foundation.utils.logger import BaseLogger
|
11
|
+
|
12
|
+
class BaseExceptions:
|
13
|
+
@staticmethod
|
14
|
+
async def validation_exception_handler(request:Request, exc:RequestValidationError):
|
15
|
+
return JSONResponse(status_code=status.HTTP_422_UNPROCESSABLE_ENTITY, content=BaseResponses.ValidationError(other=exc.errors()).model_dump())
|
16
|
+
|
17
|
+
@staticmethod
|
18
|
+
async def http_exception_handler(request:Request, exc:StarletteHTTPException):
|
19
|
+
if exc.status_code == 404:
|
20
|
+
return JSONResponse(status_code=status.HTTP_404_NOT_FOUND, content=BaseResponses.NotFound().model_dump())
|
21
|
+
|
22
|
+
#* Handle other HTTP exceptions normally
|
23
|
+
return None
|
24
|
+
|
25
|
+
@staticmethod
|
26
|
+
def database_exception_handler(
|
27
|
+
operation:str,
|
28
|
+
logger:BaseLogger,
|
29
|
+
fail_result_class:type[BaseServiceQueryResultsTransfers.Fail] = BaseServiceQueryResultsTransfers.Fail
|
30
|
+
):
|
31
|
+
"""Decorator to handle database-related exceptions consistently."""
|
32
|
+
def decorator(func):
|
33
|
+
@wraps(func)
|
34
|
+
def wrapper(*args, **kwargs):
|
35
|
+
try:
|
36
|
+
return func(*args, **kwargs)
|
37
|
+
except SQLAlchemyError as e:
|
38
|
+
logger.error("Database error occurred while %s: '%s'", operation, str(e), exc_info=True)
|
39
|
+
return fail_result_class(
|
40
|
+
message=f"Failed {operation}",
|
41
|
+
description=f"A database error occurred while {operation}. Please try again later or contact administrator.",
|
42
|
+
other="Database operation failed"
|
43
|
+
)
|
44
|
+
except Exception as e:
|
45
|
+
logger.error("Unexpected error occurred while %s: '%s'", operation, str(e), exc_info=True)
|
46
|
+
return fail_result_class(
|
47
|
+
message=f"Failed {operation}",
|
48
|
+
description=f"An unexpected error occurred while {operation}. Please try again later or contact administrator.",
|
49
|
+
other="Internal processing error"
|
50
|
+
)
|
51
|
+
return wrapper
|
52
|
+
return decorator
|
53
|
+
|
54
|
+
@staticmethod
|
55
|
+
def service_exception_handler(
|
56
|
+
operation:str,
|
57
|
+
logger:BaseLogger,
|
58
|
+
fail_result_class:type[BaseServiceGeneralResultsTransfers.Fail] = BaseServiceGeneralResultsTransfers.Fail
|
59
|
+
):
|
60
|
+
"""Decorator to handle service-related exceptions consistently."""
|
61
|
+
def decorator(func):
|
62
|
+
@wraps(func)
|
63
|
+
def wrapper(*args, **kwargs):
|
64
|
+
try:
|
65
|
+
return func(*args, **kwargs)
|
66
|
+
except Exception as e:
|
67
|
+
logger.error("Unexpected error occurred while %s: '%s'", operation, str(e), exc_info=True)
|
68
|
+
return fail_result_class(
|
69
|
+
message=f"Failed {operation}",
|
70
|
+
description=f"An unexpected error occurred while {operation}. Please try again later or contact administrator.",
|
71
|
+
other="Internal processing error"
|
72
|
+
)
|
73
|
+
return wrapper
|
74
|
+
return decorator
|
@@ -0,0 +1,37 @@
|
|
1
|
+
import re
|
2
|
+
from enum import StrEnum
|
3
|
+
|
4
|
+
class CaseFormatter:
|
5
|
+
class Case(StrEnum):
|
6
|
+
CAMEL = "camel"
|
7
|
+
PASCAL = "pascal"
|
8
|
+
SNAKE = "snake"
|
9
|
+
|
10
|
+
@staticmethod
|
11
|
+
def to_camel_case(text:str) -> str:
|
12
|
+
"""Converts snake_case or PascalCase to camelCase."""
|
13
|
+
words = re.split(r'[_\s]', text) # Handle snake_case and spaces
|
14
|
+
return words[0].lower() + "".join(word.capitalize() for word in words[1:])
|
15
|
+
|
16
|
+
@staticmethod
|
17
|
+
def to_pascal_case(text:str) -> str:
|
18
|
+
"""Converts snake_case or camelCase to PascalCase."""
|
19
|
+
words = re.split(r'[_\s]', text)
|
20
|
+
return "".join(word.capitalize() for word in words)
|
21
|
+
|
22
|
+
@staticmethod
|
23
|
+
def to_snake_case(text:str) -> str:
|
24
|
+
"""Converts camelCase or PascalCase to snake_case."""
|
25
|
+
return re.sub(r'([a-z0-9])([A-Z])', r'\1_\2', text).lower()
|
26
|
+
|
27
|
+
@staticmethod
|
28
|
+
def convert(text:str, target:Case) -> str:
|
29
|
+
"""Converts text to the specified case format."""
|
30
|
+
if target == CaseFormatter.Case.CAMEL:
|
31
|
+
return CaseFormatter.to_camel_case(text)
|
32
|
+
elif target == CaseFormatter.Case.PASCAL:
|
33
|
+
return CaseFormatter.to_pascal_case(text)
|
34
|
+
elif target == CaseFormatter.Case.SNAKE:
|
35
|
+
return CaseFormatter.to_snake_case(text)
|
36
|
+
else:
|
37
|
+
raise ValueError(f"Invalid target case: {target}.")
|
@@ -0,0 +1,68 @@
|
|
1
|
+
import logging
|
2
|
+
import os
|
3
|
+
from datetime import datetime
|
4
|
+
from maleo_foundation.clients.google.cloud.logging import GoogleCloudLogging
|
5
|
+
from maleo_foundation.models.enums import BaseEnums
|
6
|
+
|
7
|
+
class BaseLogger(logging.Logger):
|
8
|
+
def __init__(
|
9
|
+
self,
|
10
|
+
base_dir:str,
|
11
|
+
service_name:str,
|
12
|
+
category:str,
|
13
|
+
level:BaseEnums.LoggerLevel = BaseEnums.LoggerLevel.INFO
|
14
|
+
):
|
15
|
+
"""
|
16
|
+
Custom extended logger with file, console, and Google Cloud Logging.
|
17
|
+
|
18
|
+
- Logs are stored in `base_dir/logs/{category}`
|
19
|
+
- Uses Google Cloud Logging if configured
|
20
|
+
|
21
|
+
Args:
|
22
|
+
base_dir (str): Base directory for logs (e.g., "/path/to/maleo_security")
|
23
|
+
service_name (str): The service name (e.g., "maleo_security")
|
24
|
+
category (str): Log category (e.g., "application", "middleware")
|
25
|
+
"""
|
26
|
+
#* Define logger name
|
27
|
+
name = f"{service_name} - {category}"
|
28
|
+
super().__init__(name, level)
|
29
|
+
|
30
|
+
#* Clear existing handlers to prevent duplicates
|
31
|
+
for handler in list(self.handlers):
|
32
|
+
self.removeHandler(handler)
|
33
|
+
handler.close()
|
34
|
+
|
35
|
+
#* Formatter for logs
|
36
|
+
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
|
37
|
+
|
38
|
+
#* Console handler
|
39
|
+
console_handler = logging.StreamHandler()
|
40
|
+
console_handler.setFormatter(formatter)
|
41
|
+
self.addHandler(console_handler)
|
42
|
+
|
43
|
+
#* Google Cloud Logging handler (If enabled)
|
44
|
+
try:
|
45
|
+
cloud_handler = GoogleCloudLogging.create_handler(name=name.replace(" ", ""))
|
46
|
+
self.addHandler(cloud_handler)
|
47
|
+
except Exception as e:
|
48
|
+
self.warning(f"Failed to initialize Google Cloud Logging: {str(e)}")
|
49
|
+
|
50
|
+
#* Define log directory
|
51
|
+
log_dir = os.path.join(base_dir, f"logs/{category}")
|
52
|
+
os.makedirs(log_dir, exist_ok=True)
|
53
|
+
|
54
|
+
#* Generate timestamped filename
|
55
|
+
timestamp = datetime.now().strftime("%Y-%m-%d_%H-%M-%S")
|
56
|
+
log_filename = os.path.join(log_dir, f"{timestamp}.log")
|
57
|
+
|
58
|
+
#* File handler
|
59
|
+
file_handler = logging.FileHandler(log_filename, mode="a")
|
60
|
+
file_handler.setFormatter(formatter)
|
61
|
+
self.addHandler(file_handler)
|
62
|
+
|
63
|
+
def dispose(self):
|
64
|
+
"""Dispose of the logger by removing all handlers."""
|
65
|
+
for handler in list(self.handlers):
|
66
|
+
self.removeHandler(handler)
|
67
|
+
handler.close()
|
68
|
+
self.handlers.clear()
|
@@ -0,0 +1,50 @@
|
|
1
|
+
maleo_foundation/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
2
|
+
maleo_foundation/constants.py,sha256=l6WQp0nu2y4Ucs8bFcEdzVUJfR1dRM_nveuHGMhe3rY,424
|
3
|
+
maleo_foundation/controller.py,sha256=91OK1W4MnO85m0GUOQv1F8m50nlTZpZJ2HJcScH7OGA,2980
|
4
|
+
maleo_foundation/clients/__init__.py,sha256=W8vydJYeDEi6gdmOZSBFSSDsfZJtb8C05CHErZgsZ30,188
|
5
|
+
maleo_foundation/clients/general/__init__.py,sha256=l9eQrBeLW4aXtGU5aK3i6fD-msVR4526W7D9V8WCXIg,91
|
6
|
+
maleo_foundation/clients/general/http.py,sha256=cE-sYlC1fXURwxE1d8pgNoUU9GKKSlPbwqF4EbslX8Q,1361
|
7
|
+
maleo_foundation/clients/google/__init__.py,sha256=1uv6nF9QbATsSAcMimQOT7Y-eBljjDunBojNX6oAtS8,90
|
8
|
+
maleo_foundation/clients/google/cloud/__init__.py,sha256=WGMPxEKKdkz3XGY5dZn9E-nYhD1kv1MgRHbmVnky4zk,245
|
9
|
+
maleo_foundation/clients/google/cloud/logging.py,sha256=l8EL8rZAf1uatMil_ARmRL0z4K4iX2HqUUpdctNGXMw,1584
|
10
|
+
maleo_foundation/clients/google/cloud/secret.py,sha256=cFewA-EYsAaEfxc2G2XGzwHreW1FgyCK6MpwOARE24M,3452
|
11
|
+
maleo_foundation/clients/google/cloud/storage.py,sha256=y_HAsbcGSnu5sxZPxaQWFWvOlF3vEcqkej2834OgAS0,2617
|
12
|
+
maleo_foundation/db/__init__.py,sha256=fFqGxpsiowiws70AqOfcOWFhwaahfOj9_05JSJ0iRaE,107
|
13
|
+
maleo_foundation/db/database.py,sha256=RQBWeUearfrgq2L8-8cFVBByjNku9OiY3AmucRWXUOw,2064
|
14
|
+
maleo_foundation/db/engine.py,sha256=kw2SMMiWy5KARquh4TLk7v6HwlHW97lUIUvqdFbhNxk,1600
|
15
|
+
maleo_foundation/db/session.py,sha256=tI13DJ6rLo8FOpSIFZrmD4dbuxY_c0RTjwEGb76ZOo0,2681
|
16
|
+
maleo_foundation/models/__init__.py,sha256=Wh92XAduE1Sg9qi2GMhptyXig0fKcTS5AbGo3tE3tLs,348
|
17
|
+
maleo_foundation/models/enums.py,sha256=4tEr9a8jevEvLwwxTGRxXOtqwmmD_Ftcxo8IXUbMBA8,2074
|
18
|
+
maleo_foundation/models/responses.py,sha256=z2XEHwuxU05NDJSgrA7B7e2fzEQP6Kl3ZM2BO-lDw_A,3786
|
19
|
+
maleo_foundation/models/schemas/__init__.py,sha256=Xj8Ahsqyra-fmEaVcGPok5GOOsPQlKcknHYMvbjvENA,277
|
20
|
+
maleo_foundation/models/schemas/general.py,sha256=cMi3Onimzn3_wZdKMV-ufl25_xQVw3WaUaJOOZko9Z4,4813
|
21
|
+
maleo_foundation/models/schemas/parameter.py,sha256=1og_crWds6YLS-8Ha5EbAi3ZaNMzNFiIZ06v_HO3b9k,875
|
22
|
+
maleo_foundation/models/schemas/result.py,sha256=KffY-qrCn2ES4AHtEaCE_eOQH-8DNrcZMM2FZtUNJKc,4180
|
23
|
+
maleo_foundation/models/transfers/__init__.py,sha256=B8oCZHE3NTsrJ_rviSXaDsuc-gc25jpjuhJO40lpQiE,222
|
24
|
+
maleo_foundation/models/transfers/parameters/__init__.py,sha256=oKW4RPIEISISRjsJzD8lsCGY1HhZRTzshPpWHcJu86k,353
|
25
|
+
maleo_foundation/models/transfers/parameters/client.py,sha256=oi9LzEIFAg1WVbsnmVegsn8kLDt6tJJbOZLrhfQjs64,2248
|
26
|
+
maleo_foundation/models/transfers/parameters/general.py,sha256=TDDUAc7GsKA9jhpan5BqoGVpOcwJPHpV34atXEd0D60,532
|
27
|
+
maleo_foundation/models/transfers/parameters/service.py,sha256=_bOhpwxHHDJseURwPFFUZsK1cyekKbxoXaXEbpmjJ7c,5331
|
28
|
+
maleo_foundation/models/transfers/results/__init__.py,sha256=0_8uJ1IQW87RZ4nIxzWkQVi3Fxb7B8myZTngXfoxgNc,241
|
29
|
+
maleo_foundation/models/transfers/results/client/__init__.py,sha256=xBRuY0NUIPpQEGQ2qoBnqLZGX4W1YSrQ0VnDf5OYJBo,290
|
30
|
+
maleo_foundation/models/transfers/results/client/service.py,sha256=TO_U53vmUEnFWiiyuu33ao3BUidt6KFxvk3GC9uo8JE,1108
|
31
|
+
maleo_foundation/models/transfers/results/client/controllers/__init__.py,sha256=x5pcJ33rsG8SqecwL1g762DFoySisTLbZqOqKqKoaKU,173
|
32
|
+
maleo_foundation/models/transfers/results/client/controllers/http.py,sha256=vhjfjchvlTq347mLY2mcE84n_xYMpLkALi_ecQNOAGY,1499
|
33
|
+
maleo_foundation/models/transfers/results/service/__init__.py,sha256=dTjHe1iGIpdulrzawQoOj003sxxObumF63YpUptKrDA,390
|
34
|
+
maleo_foundation/models/transfers/results/service/general.py,sha256=G4x-MhQI7Km9UAcx2uJmrsqA6RBvxpH6VFAd_ynFFd4,1486
|
35
|
+
maleo_foundation/models/transfers/results/service/query.py,sha256=ICU2589n4n5czxWd9yo9_Eh9TukUJyuUk_xRrRFNL5w,1592
|
36
|
+
maleo_foundation/models/transfers/results/service/controllers/__init__.py,sha256=HZJWMy2dskzOCzLmp_UaL9rjbQ-sDMI7sd2bXb-4QOU,175
|
37
|
+
maleo_foundation/models/transfers/results/service/controllers/rest.py,sha256=bZ4NibT58aim6p3epFJ9ipR8Z54FkOuFx2GniK4CUfM,1114
|
38
|
+
maleo_foundation/models/types/__init__.py,sha256=0QYcK_1Ekj9W_o_ZVawkBS7Xc25A9j5KY2DRBKmljOI,247
|
39
|
+
maleo_foundation/models/types/client.py,sha256=tZtuMI_4uLxEiOvuGrwznEzMpqt3EEb3Z4t_VwzVtI0,1578
|
40
|
+
maleo_foundation/models/types/query.py,sha256=wq5bCbph19PjcpEuAh58B330jopSUG64KGsoi9SFuN4,1567
|
41
|
+
maleo_foundation/models/types/service.py,sha256=utK9TACldhE0WW75KN84F_9D-fM5l1xN5_3F6QUVfPs,1595
|
42
|
+
maleo_foundation/utils/__init__.py,sha256=tfgaHZI2PDgxEVSQztfnDMN5S6L5Y4FcK5v_Wkf5snE,245
|
43
|
+
maleo_foundation/utils/exceptions.py,sha256=mcvBwHm6uWpVQkPtO1T2j-GaTYEiyPOeGxiDL9-sjNA,3639
|
44
|
+
maleo_foundation/utils/logger.py,sha256=ICrFi0MxuAjDy8KTRL7pex1miwzZqZX-HHArgN3niJM,2453
|
45
|
+
maleo_foundation/utils/formatter/__init__.py,sha256=iKf5YCbEdg1qKnFHyKqqcQbqAqEeRUf8mhI3v3dQoj8,78
|
46
|
+
maleo_foundation/utils/formatter/case.py,sha256=TmvvlfzGdC_omMTB5vAa40TZBxQ3hnr-SYeo0M52Rlg,1352
|
47
|
+
maleo_foundation-0.0.2.dist-info/METADATA,sha256=BjDY-k-f58-j7b4v-ae_i7liFamCaNPvZCnfgzdYXcQ,3159
|
48
|
+
maleo_foundation-0.0.2.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
|
49
|
+
maleo_foundation-0.0.2.dist-info/top_level.txt,sha256=_iBos3F_bhEOdjOnzeiEYSrCucasc810xXtLBXI8cQc,17
|
50
|
+
maleo_foundation-0.0.2.dist-info/RECORD,,
|
@@ -0,0 +1 @@
|
|
1
|
+
maleo_foundation
|
@@ -1,4 +0,0 @@
|
|
1
|
-
maleo_foundation-0.0.1.dist-info/METADATA,sha256=CqeCnXvlglm4GbltDaYHw7P1gM2aSmuP5vPcPuY9HaI,3159
|
2
|
-
maleo_foundation-0.0.1.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
|
3
|
-
maleo_foundation-0.0.1.dist-info/top_level.txt,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
4
|
-
maleo_foundation-0.0.1.dist-info/RECORD,,
|
@@ -1 +0,0 @@
|
|
1
|
-
|
File without changes
|