added logging config for init monitor
This commit is contained in:
1 parent
4ac8692539
commit
c13e0d3c77
6 files changed
+26
-22
No files matched your search
@@ -16,6 +16,7 @@ dependencies = [
|
|||||||
"pymongo>=4.17.0",
|
"pymongo>=4.17.0",
|
||||||
"requests>=2.34.2",
|
"requests>=2.34.2",
|
||||||
"tenacity>=9.1.4",
|
"tenacity>=9.1.4",
|
||||||
|
"log-setup @ git+https://git.rethinkstudios.io/rethink-public/log_setup.git@main",
|
||||||
]
|
]
|
||||||
|
|
||||||
[tool.setuptools.packages.find]
|
[tool.setuptools.packages.find]
|
||||||
|
|||||||
@@ -1,13 +1,9 @@
|
|||||||
import logging
|
|
||||||
import json
|
import json
|
||||||
|
import logging
|
||||||
import pathlib
|
import pathlib
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
|
|
||||||
from monitor_utils.constants import (
|
from monitor_utils.constants import DEVELOPMENT_BOT_TOKEN, LOGGERS, PRODUCTION_BOT_TOKEN
|
||||||
PRODUCTION_BOT_TOKEN,
|
|
||||||
DEVELOPMENT_BOT_TOKEN,
|
|
||||||
LOGGERS,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class DevelopmentMode(str, Enum):
|
class DevelopmentMode(str, Enum):
|
||||||
|
|||||||
@@ -7,8 +7,8 @@ from motor.motor_asyncio import AsyncIOMotorClient, AsyncIOMotorCollection
|
|||||||
from pymongo import UpdateOne
|
from pymongo import UpdateOne
|
||||||
from pymongo.errors import PyMongoError
|
from pymongo.errors import PyMongoError
|
||||||
|
|
||||||
|
from monitor_utils.constants import MONGO_DATABASE_NAME, MONGO_URL, STATUS_PENDING
|
||||||
from monitor_utils.models import Product
|
from monitor_utils.models import Product
|
||||||
from monitor_utils.constants import STATUS_PENDING, MONGO_DATABASE_NAME, MONGO_URL
|
|
||||||
|
|
||||||
LOGGER = logging.getLogger(__name__)
|
LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
from datetime import datetime
|
|
||||||
from dataclasses import field
|
from dataclasses import field
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
from pydantic.dataclasses import dataclass
|
from pydantic.dataclasses import dataclass
|
||||||
|
|
||||||
|
|||||||
+18
-11
@@ -6,36 +6,43 @@ from typing import Awaitable, Callable, Iterable
|
|||||||
import aiohttp
|
import aiohttp
|
||||||
from aioproxies import AioProxies
|
from aioproxies import AioProxies
|
||||||
from curl_cffi.requests import AsyncSession
|
from curl_cffi.requests import AsyncSession
|
||||||
|
from log_setup import setup_logging
|
||||||
from motor.motor_asyncio import AsyncIOMotorCollection
|
from motor.motor_asyncio import AsyncIOMotorCollection
|
||||||
|
|
||||||
from aioproxies import AioProxies
|
|
||||||
from monitor_utils.constants import (
|
|
||||||
EXPECTED_TASK_ERRORS,
|
|
||||||
FLAG_WEBHOOK_MAP,
|
|
||||||
BUCKET_WEBHOOK_MAP,
|
|
||||||
)
|
|
||||||
from monitor_utils.config import (
|
from monitor_utils.config import (
|
||||||
|
DevelopmentMode,
|
||||||
get_config,
|
get_config,
|
||||||
is_production,
|
is_production,
|
||||||
set_logger_levels,
|
set_logger_levels,
|
||||||
DevelopmentMode,
|
|
||||||
)
|
)
|
||||||
|
from monitor_utils.constants import (
|
||||||
|
BUCKET_WEBHOOK_MAP,
|
||||||
|
EXPECTED_TASK_ERRORS,
|
||||||
|
FLAG_WEBHOOK_MAP,
|
||||||
|
LOGGING_LEVEL,
|
||||||
|
)
|
||||||
|
from monitor_utils.database import get_collection
|
||||||
from monitor_utils.models import (
|
from monitor_utils.models import (
|
||||||
|
AvailabilityInfo,
|
||||||
|
PricingInfo,
|
||||||
Product,
|
Product,
|
||||||
ProductMetadata,
|
ProductMetadata,
|
||||||
ProductTiming,
|
ProductTiming,
|
||||||
PricingInfo,
|
|
||||||
AvailabilityInfo,
|
|
||||||
)
|
)
|
||||||
from monitor_utils.sessions import get_base_session, get_tls_session
|
from monitor_utils.sessions import get_base_session, get_tls_session
|
||||||
from monitor_utils.database import get_collection
|
|
||||||
|
|
||||||
LOGGER = logging.getLogger(__name__)
|
LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def init_monitor(
|
def init_monitor(
|
||||||
monitor_name: str, development_mode: DevelopmentMode, proxy_path: str
|
monitor_name: str,
|
||||||
|
development_mode: DevelopmentMode,
|
||||||
|
proxy_path: str,
|
||||||
|
logging_level=LOGGING_LEVEL,
|
||||||
) -> tuple[list[str], AsyncIOMotorCollection, AioProxies]:
|
) -> tuple[list[str], AsyncIOMotorCollection, AioProxies]:
|
||||||
|
setup_logging(
|
||||||
|
name="logs/latest.log", history_name="apple", level=logging_level, output="json"
|
||||||
|
)
|
||||||
set_logger_levels()
|
set_logger_levels()
|
||||||
category_names, _, collection = setup_config(
|
category_names, _, collection = setup_config(
|
||||||
monitor_name=monitor_name, development_mode=development_mode
|
monitor_name=monitor_name, development_mode=development_mode
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
# ik ua/tls doesn't match headers/header order but targeted antibots don't seem to care might fix later
|
# ik ua/tls doesn't match headers/header order but targeted antibots don't seem to care might fix later
|
||||||
import asyncio
|
import asyncio
|
||||||
import random
|
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
|
import random
|
||||||
from contextlib import asynccontextmanager
|
from contextlib import asynccontextmanager
|
||||||
from typing import AsyncGenerator
|
from typing import AsyncGenerator
|
||||||
|
|
||||||
@@ -23,11 +23,11 @@ from tenacity import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
from monitor_utils.constants import (
|
from monitor_utils.constants import (
|
||||||
CLIENT_TIMEOUT,
|
|
||||||
TIMEOUT_SECONDS,
|
|
||||||
CLIENT_IDENTIFIERS,
|
CLIENT_IDENTIFIERS,
|
||||||
|
CLIENT_TIMEOUT,
|
||||||
RETRY_LIMIT,
|
RETRY_LIMIT,
|
||||||
RETRY_WAIT,
|
RETRY_WAIT,
|
||||||
|
TIMEOUT_SECONDS,
|
||||||
)
|
)
|
||||||
|
|
||||||
LOGGER = logging.getLogger(__name__)
|
LOGGER = logging.getLogger(__name__)
|
||||||
|
|||||||
Reference in new issue
Block a user