unrealon 1.0.9__py3-none-any.whl → 1.1.0__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.
- unrealon/__init__.py +23 -21
- unrealon-1.1.0.dist-info/METADATA +164 -0
- unrealon-1.1.0.dist-info/RECORD +82 -0
- {unrealon-1.0.9.dist-info → unrealon-1.1.0.dist-info}/WHEEL +1 -1
- unrealon-1.1.0.dist-info/entry_points.txt +9 -0
- {unrealon-1.0.9.dist-info → unrealon-1.1.0.dist-info/licenses}/LICENSE +1 -1
- unrealon_bridge/__init__.py +114 -0
- unrealon_bridge/cli.py +316 -0
- unrealon_bridge/client/__init__.py +93 -0
- unrealon_bridge/client/base.py +78 -0
- unrealon_bridge/client/commands.py +89 -0
- unrealon_bridge/client/connection.py +90 -0
- unrealon_bridge/client/events.py +65 -0
- unrealon_bridge/client/health.py +38 -0
- unrealon_bridge/client/html_parser.py +146 -0
- unrealon_bridge/client/logging.py +139 -0
- unrealon_bridge/client/proxy.py +70 -0
- unrealon_bridge/client/scheduler.py +450 -0
- unrealon_bridge/client/session.py +70 -0
- unrealon_bridge/configs/__init__.py +14 -0
- unrealon_bridge/configs/bridge_config.py +212 -0
- unrealon_bridge/configs/bridge_config.yaml +39 -0
- unrealon_bridge/models/__init__.py +138 -0
- unrealon_bridge/models/base.py +28 -0
- unrealon_bridge/models/command.py +41 -0
- unrealon_bridge/models/events.py +40 -0
- unrealon_bridge/models/html_parser.py +79 -0
- unrealon_bridge/models/logging.py +55 -0
- unrealon_bridge/models/parser.py +63 -0
- unrealon_bridge/models/proxy.py +41 -0
- unrealon_bridge/models/requests.py +95 -0
- unrealon_bridge/models/responses.py +88 -0
- unrealon_bridge/models/scheduler.py +592 -0
- unrealon_bridge/models/session.py +28 -0
- unrealon_bridge/server/__init__.py +91 -0
- unrealon_bridge/server/base.py +171 -0
- unrealon_bridge/server/handlers/__init__.py +23 -0
- unrealon_bridge/server/handlers/command.py +110 -0
- unrealon_bridge/server/handlers/html_parser.py +139 -0
- unrealon_bridge/server/handlers/logging.py +95 -0
- unrealon_bridge/server/handlers/parser.py +95 -0
- unrealon_bridge/server/handlers/proxy.py +75 -0
- unrealon_bridge/server/handlers/scheduler.py +545 -0
- unrealon_bridge/server/handlers/session.py +66 -0
- unrealon_browser/__init__.py +61 -18
- unrealon_browser/{src/cli → cli}/browser_cli.py +6 -13
- unrealon_browser/{src/cli → cli}/cookies_cli.py +5 -1
- unrealon_browser/{src/core → core}/browser_manager.py +2 -2
- unrealon_browser/{src/managers → managers}/captcha.py +1 -1
- unrealon_browser/{src/managers → managers}/cookies.py +1 -1
- unrealon_browser/managers/logger_bridge.py +231 -0
- unrealon_browser/{src/managers → managers}/profile.py +1 -1
- unrealon_driver/__init__.py +73 -19
- unrealon_driver/browser/__init__.py +8 -0
- unrealon_driver/browser/config.py +74 -0
- unrealon_driver/browser/manager.py +416 -0
- unrealon_driver/exceptions.py +28 -0
- unrealon_driver/parser/__init__.py +55 -0
- unrealon_driver/parser/cli_manager.py +141 -0
- unrealon_driver/parser/daemon_manager.py +227 -0
- unrealon_driver/parser/managers/__init__.py +46 -0
- unrealon_driver/parser/managers/browser.py +51 -0
- unrealon_driver/parser/managers/config.py +281 -0
- unrealon_driver/parser/managers/error.py +412 -0
- unrealon_driver/parser/managers/html.py +732 -0
- unrealon_driver/parser/managers/logging.py +609 -0
- unrealon_driver/parser/managers/result.py +321 -0
- unrealon_driver/parser/parser_manager.py +628 -0
- unrealon/sdk_config.py +0 -88
- unrealon-1.0.9.dist-info/METADATA +0 -810
- unrealon-1.0.9.dist-info/RECORD +0 -246
- unrealon_browser/pyproject.toml +0 -182
- unrealon_browser/src/__init__.py +0 -62
- unrealon_browser/src/managers/logger_bridge.py +0 -395
- unrealon_driver/README.md +0 -204
- unrealon_driver/pyproject.toml +0 -187
- unrealon_driver/src/__init__.py +0 -90
- unrealon_driver/src/cli/__init__.py +0 -10
- unrealon_driver/src/cli/main.py +0 -66
- unrealon_driver/src/cli/simple.py +0 -510
- unrealon_driver/src/config/__init__.py +0 -11
- unrealon_driver/src/config/auto_config.py +0 -478
- unrealon_driver/src/core/__init__.py +0 -18
- unrealon_driver/src/core/exceptions.py +0 -289
- unrealon_driver/src/core/parser.py +0 -638
- unrealon_driver/src/dto/__init__.py +0 -66
- unrealon_driver/src/dto/cli.py +0 -119
- unrealon_driver/src/dto/config.py +0 -18
- unrealon_driver/src/dto/events.py +0 -237
- unrealon_driver/src/dto/execution.py +0 -313
- unrealon_driver/src/dto/services.py +0 -311
- unrealon_driver/src/execution/__init__.py +0 -23
- unrealon_driver/src/execution/daemon_mode.py +0 -317
- unrealon_driver/src/execution/interactive_mode.py +0 -88
- unrealon_driver/src/execution/modes.py +0 -45
- unrealon_driver/src/execution/scheduled_mode.py +0 -209
- unrealon_driver/src/execution/test_mode.py +0 -250
- unrealon_driver/src/logging/__init__.py +0 -24
- unrealon_driver/src/logging/driver_logger.py +0 -512
- unrealon_driver/src/services/__init__.py +0 -24
- unrealon_driver/src/services/browser_service.py +0 -726
- unrealon_driver/src/services/llm/__init__.py +0 -15
- unrealon_driver/src/services/llm/browser_llm_service.py +0 -363
- unrealon_driver/src/services/llm/llm.py +0 -195
- unrealon_driver/src/services/logger_service.py +0 -232
- unrealon_driver/src/services/metrics_service.py +0 -185
- unrealon_driver/src/services/scheduler_service.py +0 -489
- unrealon_driver/src/services/websocket_service.py +0 -362
- unrealon_driver/src/utils/__init__.py +0 -16
- unrealon_driver/src/utils/service_factory.py +0 -317
- unrealon_driver/src/utils/time_formatter.py +0 -338
- unrealon_llm/README.md +0 -44
- unrealon_llm/__init__.py +0 -26
- unrealon_llm/pyproject.toml +0 -154
- unrealon_llm/src/__init__.py +0 -228
- unrealon_llm/src/cli/__init__.py +0 -0
- unrealon_llm/src/core/__init__.py +0 -11
- unrealon_llm/src/core/smart_client.py +0 -438
- unrealon_llm/src/dto/__init__.py +0 -155
- unrealon_llm/src/dto/models/__init__.py +0 -0
- unrealon_llm/src/dto/models/config.py +0 -343
- unrealon_llm/src/dto/models/core.py +0 -328
- unrealon_llm/src/dto/models/enums.py +0 -123
- unrealon_llm/src/dto/models/html_analysis.py +0 -345
- unrealon_llm/src/dto/models/statistics.py +0 -473
- unrealon_llm/src/dto/models/translation.py +0 -383
- unrealon_llm/src/dto/models/type_conversion.py +0 -462
- unrealon_llm/src/dto/schemas/__init__.py +0 -0
- unrealon_llm/src/exceptions.py +0 -392
- unrealon_llm/src/llm_config/__init__.py +0 -20
- unrealon_llm/src/llm_config/logging_config.py +0 -178
- unrealon_llm/src/llm_logging/__init__.py +0 -42
- unrealon_llm/src/llm_logging/llm_events.py +0 -107
- unrealon_llm/src/llm_logging/llm_logger.py +0 -466
- unrealon_llm/src/managers/__init__.py +0 -15
- unrealon_llm/src/managers/cache_manager.py +0 -67
- unrealon_llm/src/managers/cost_manager.py +0 -107
- unrealon_llm/src/managers/request_manager.py +0 -298
- unrealon_llm/src/modules/__init__.py +0 -0
- unrealon_llm/src/modules/html_processor/__init__.py +0 -25
- unrealon_llm/src/modules/html_processor/base_processor.py +0 -415
- unrealon_llm/src/modules/html_processor/details_processor.py +0 -85
- unrealon_llm/src/modules/html_processor/listing_processor.py +0 -91
- unrealon_llm/src/modules/html_processor/models/__init__.py +0 -20
- unrealon_llm/src/modules/html_processor/models/processing_models.py +0 -40
- unrealon_llm/src/modules/html_processor/models/universal_model.py +0 -56
- unrealon_llm/src/modules/html_processor/processor.py +0 -102
- unrealon_llm/src/modules/llm/__init__.py +0 -0
- unrealon_llm/src/modules/translator/__init__.py +0 -0
- unrealon_llm/src/provider.py +0 -116
- unrealon_llm/src/utils/__init__.py +0 -95
- unrealon_llm/src/utils/common.py +0 -64
- unrealon_llm/src/utils/data_extractor.py +0 -188
- unrealon_llm/src/utils/html_cleaner.py +0 -767
- unrealon_llm/src/utils/language_detector.py +0 -308
- unrealon_llm/src/utils/models_cache.py +0 -592
- unrealon_llm/src/utils/smart_counter.py +0 -229
- unrealon_llm/src/utils/token_counter.py +0 -189
- unrealon_sdk/README.md +0 -25
- unrealon_sdk/__init__.py +0 -30
- unrealon_sdk/pyproject.toml +0 -231
- unrealon_sdk/src/__init__.py +0 -150
- unrealon_sdk/src/cli/__init__.py +0 -12
- unrealon_sdk/src/cli/commands/__init__.py +0 -22
- unrealon_sdk/src/cli/commands/benchmark.py +0 -42
- unrealon_sdk/src/cli/commands/diagnostics.py +0 -573
- unrealon_sdk/src/cli/commands/health.py +0 -46
- unrealon_sdk/src/cli/commands/integration.py +0 -498
- unrealon_sdk/src/cli/commands/reports.py +0 -43
- unrealon_sdk/src/cli/commands/security.py +0 -36
- unrealon_sdk/src/cli/commands/server.py +0 -483
- unrealon_sdk/src/cli/commands/servers.py +0 -56
- unrealon_sdk/src/cli/commands/tests.py +0 -55
- unrealon_sdk/src/cli/main.py +0 -126
- unrealon_sdk/src/cli/utils/reporter.py +0 -519
- unrealon_sdk/src/clients/openapi.yaml +0 -3347
- unrealon_sdk/src/clients/python_http/__init__.py +0 -3
- unrealon_sdk/src/clients/python_http/api_config.py +0 -228
- unrealon_sdk/src/clients/python_http/models/BaseModel.py +0 -12
- unrealon_sdk/src/clients/python_http/models/BroadcastDeliveryStats.py +0 -33
- unrealon_sdk/src/clients/python_http/models/BroadcastMessage.py +0 -17
- unrealon_sdk/src/clients/python_http/models/BroadcastMessageRequest.py +0 -35
- unrealon_sdk/src/clients/python_http/models/BroadcastPriority.py +0 -10
- unrealon_sdk/src/clients/python_http/models/BroadcastResponse.py +0 -21
- unrealon_sdk/src/clients/python_http/models/BroadcastResultResponse.py +0 -33
- unrealon_sdk/src/clients/python_http/models/BroadcastTarget.py +0 -11
- unrealon_sdk/src/clients/python_http/models/ConnectionStats.py +0 -27
- unrealon_sdk/src/clients/python_http/models/ConnectionsResponse.py +0 -21
- unrealon_sdk/src/clients/python_http/models/DeveloperMessageResponse.py +0 -23
- unrealon_sdk/src/clients/python_http/models/ErrorResponse.py +0 -25
- unrealon_sdk/src/clients/python_http/models/HTTPValidationError.py +0 -16
- unrealon_sdk/src/clients/python_http/models/HealthResponse.py +0 -23
- unrealon_sdk/src/clients/python_http/models/HealthStatus.py +0 -33
- unrealon_sdk/src/clients/python_http/models/LogLevel.py +0 -10
- unrealon_sdk/src/clients/python_http/models/LoggingRequest.py +0 -27
- unrealon_sdk/src/clients/python_http/models/LoggingResponse.py +0 -23
- unrealon_sdk/src/clients/python_http/models/MaintenanceMode.py +0 -9
- unrealon_sdk/src/clients/python_http/models/MaintenanceModeRequest.py +0 -33
- unrealon_sdk/src/clients/python_http/models/MaintenanceStatusResponse.py +0 -39
- unrealon_sdk/src/clients/python_http/models/ParserCommandRequest.py +0 -25
- unrealon_sdk/src/clients/python_http/models/ParserMessageResponse.py +0 -21
- unrealon_sdk/src/clients/python_http/models/ParserRegistrationRequest.py +0 -28
- unrealon_sdk/src/clients/python_http/models/ParserRegistrationResponse.py +0 -25
- unrealon_sdk/src/clients/python_http/models/ParserType.py +0 -10
- unrealon_sdk/src/clients/python_http/models/ProxyBlockRequest.py +0 -19
- unrealon_sdk/src/clients/python_http/models/ProxyEndpointResponse.py +0 -20
- unrealon_sdk/src/clients/python_http/models/ProxyListResponse.py +0 -19
- unrealon_sdk/src/clients/python_http/models/ProxyProvider.py +0 -10
- unrealon_sdk/src/clients/python_http/models/ProxyPurchaseRequest.py +0 -25
- unrealon_sdk/src/clients/python_http/models/ProxyResponse.py +0 -47
- unrealon_sdk/src/clients/python_http/models/ProxyRotationRequest.py +0 -23
- unrealon_sdk/src/clients/python_http/models/ProxyStatus.py +0 -10
- unrealon_sdk/src/clients/python_http/models/ProxyUsageRequest.py +0 -19
- unrealon_sdk/src/clients/python_http/models/ProxyUsageStatsResponse.py +0 -26
- unrealon_sdk/src/clients/python_http/models/ServiceRegistrationDto.py +0 -23
- unrealon_sdk/src/clients/python_http/models/ServiceStatsResponse.py +0 -31
- unrealon_sdk/src/clients/python_http/models/SessionStartRequest.py +0 -23
- unrealon_sdk/src/clients/python_http/models/SuccessResponse.py +0 -25
- unrealon_sdk/src/clients/python_http/models/SystemNotificationResponse.py +0 -23
- unrealon_sdk/src/clients/python_http/models/ValidationError.py +0 -18
- unrealon_sdk/src/clients/python_http/models/ValidationErrorResponse.py +0 -21
- unrealon_sdk/src/clients/python_http/models/WebSocketMetrics.py +0 -21
- unrealon_sdk/src/clients/python_http/models/__init__.py +0 -44
- unrealon_sdk/src/clients/python_http/services/None_service.py +0 -35
- unrealon_sdk/src/clients/python_http/services/ParserManagement_service.py +0 -190
- unrealon_sdk/src/clients/python_http/services/ProxyManagement_service.py +0 -289
- unrealon_sdk/src/clients/python_http/services/SocketLogging_service.py +0 -187
- unrealon_sdk/src/clients/python_http/services/SystemHealth_service.py +0 -119
- unrealon_sdk/src/clients/python_http/services/WebSocketAPI_service.py +0 -198
- unrealon_sdk/src/clients/python_http/services/__init__.py +0 -0
- unrealon_sdk/src/clients/python_http/services/admin_service.py +0 -125
- unrealon_sdk/src/clients/python_http/services/async_None_service.py +0 -35
- unrealon_sdk/src/clients/python_http/services/async_ParserManagement_service.py +0 -190
- unrealon_sdk/src/clients/python_http/services/async_ProxyManagement_service.py +0 -289
- unrealon_sdk/src/clients/python_http/services/async_SocketLogging_service.py +0 -189
- unrealon_sdk/src/clients/python_http/services/async_SystemHealth_service.py +0 -123
- unrealon_sdk/src/clients/python_http/services/async_WebSocketAPI_service.py +0 -200
- unrealon_sdk/src/clients/python_http/services/async_admin_service.py +0 -125
- unrealon_sdk/src/clients/python_websocket/__init__.py +0 -28
- unrealon_sdk/src/clients/python_websocket/client.py +0 -490
- unrealon_sdk/src/clients/python_websocket/events.py +0 -732
- unrealon_sdk/src/clients/python_websocket/example.py +0 -136
- unrealon_sdk/src/clients/python_websocket/types.py +0 -871
- unrealon_sdk/src/core/__init__.py +0 -64
- unrealon_sdk/src/core/client.py +0 -556
- unrealon_sdk/src/core/config.py +0 -465
- unrealon_sdk/src/core/exceptions.py +0 -239
- unrealon_sdk/src/core/metadata.py +0 -191
- unrealon_sdk/src/core/models.py +0 -142
- unrealon_sdk/src/core/types.py +0 -68
- unrealon_sdk/src/dto/__init__.py +0 -268
- unrealon_sdk/src/dto/authentication.py +0 -108
- unrealon_sdk/src/dto/cache.py +0 -208
- unrealon_sdk/src/dto/common.py +0 -19
- unrealon_sdk/src/dto/concurrency.py +0 -393
- unrealon_sdk/src/dto/events.py +0 -108
- unrealon_sdk/src/dto/health.py +0 -339
- unrealon_sdk/src/dto/load_balancing.py +0 -336
- unrealon_sdk/src/dto/logging.py +0 -230
- unrealon_sdk/src/dto/performance.py +0 -165
- unrealon_sdk/src/dto/rate_limiting.py +0 -295
- unrealon_sdk/src/dto/resource_pooling.py +0 -128
- unrealon_sdk/src/dto/structured_logging.py +0 -112
- unrealon_sdk/src/dto/task_scheduling.py +0 -121
- unrealon_sdk/src/dto/websocket.py +0 -55
- unrealon_sdk/src/enterprise/__init__.py +0 -59
- unrealon_sdk/src/enterprise/authentication.py +0 -401
- unrealon_sdk/src/enterprise/cache_manager.py +0 -578
- unrealon_sdk/src/enterprise/error_recovery.py +0 -494
- unrealon_sdk/src/enterprise/event_system.py +0 -549
- unrealon_sdk/src/enterprise/health_monitor.py +0 -747
- unrealon_sdk/src/enterprise/load_balancer.py +0 -964
- unrealon_sdk/src/enterprise/logging/__init__.py +0 -68
- unrealon_sdk/src/enterprise/logging/cleanup.py +0 -156
- unrealon_sdk/src/enterprise/logging/development.py +0 -744
- unrealon_sdk/src/enterprise/logging/service.py +0 -410
- unrealon_sdk/src/enterprise/multithreading_manager.py +0 -853
- unrealon_sdk/src/enterprise/performance_monitor.py +0 -539
- unrealon_sdk/src/enterprise/proxy_manager.py +0 -696
- unrealon_sdk/src/enterprise/rate_limiter.py +0 -652
- unrealon_sdk/src/enterprise/resource_pool.py +0 -763
- unrealon_sdk/src/enterprise/task_scheduler.py +0 -709
- unrealon_sdk/src/internal/__init__.py +0 -10
- unrealon_sdk/src/internal/command_router.py +0 -497
- unrealon_sdk/src/internal/connection_manager.py +0 -397
- unrealon_sdk/src/internal/http_client.py +0 -446
- unrealon_sdk/src/internal/websocket_client.py +0 -420
- unrealon_sdk/src/provider.py +0 -471
- unrealon_sdk/src/utils.py +0 -234
- /unrealon_browser/{src/cli → cli}/__init__.py +0 -0
- /unrealon_browser/{src/cli → cli}/interactive_mode.py +0 -0
- /unrealon_browser/{src/cli → cli}/main.py +0 -0
- /unrealon_browser/{src/core → core}/__init__.py +0 -0
- /unrealon_browser/{src/dto → dto}/__init__.py +0 -0
- /unrealon_browser/{src/dto → dto}/models/config.py +0 -0
- /unrealon_browser/{src/dto → dto}/models/core.py +0 -0
- /unrealon_browser/{src/dto → dto}/models/dataclasses.py +0 -0
- /unrealon_browser/{src/dto → dto}/models/detection.py +0 -0
- /unrealon_browser/{src/dto → dto}/models/enums.py +0 -0
- /unrealon_browser/{src/dto → dto}/models/statistics.py +0 -0
- /unrealon_browser/{src/managers → managers}/__init__.py +0 -0
- /unrealon_browser/{src/managers → managers}/stealth.py +0 -0
|
@@ -1,512 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Driver Logger v3.0 - Specialized logging for UnrealOn Driver
|
|
3
|
-
|
|
4
|
-
Wraps the SDK DevelopmentLogger with Driver-specific convenience methods.
|
|
5
|
-
Provides structured logging for browser automation, data extraction, and system monitoring.
|
|
6
|
-
Following zero-configuration philosophy of Driver v3.0.
|
|
7
|
-
"""
|
|
8
|
-
|
|
9
|
-
import asyncio
|
|
10
|
-
import logging
|
|
11
|
-
import os
|
|
12
|
-
from pathlib import Path
|
|
13
|
-
from typing import Optional, Dict, Any, List
|
|
14
|
-
from datetime import datetime, timezone
|
|
15
|
-
|
|
16
|
-
from unrealon_sdk.src.enterprise.logging.development import (
|
|
17
|
-
DevelopmentLogger,
|
|
18
|
-
initialize_development_logger,
|
|
19
|
-
get_development_logger,
|
|
20
|
-
)
|
|
21
|
-
from unrealon_sdk.src.dto.logging import SDKEventType, SDKSeverity, SDKContext
|
|
22
|
-
from unrealon_driver.src.dto.events import DriverEventType
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
# Global driver logger instance for zero-configuration
|
|
26
|
-
_driver_logger: Optional["DriverLogger"] = None
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
def initialize_driver_logger(
|
|
30
|
-
parser_id: str = "unknown",
|
|
31
|
-
parser_name: str = "UnrealOn Parser",
|
|
32
|
-
log_level: str = "INFO",
|
|
33
|
-
enable_console: bool = True,
|
|
34
|
-
enable_websocket: bool = False,
|
|
35
|
-
system_dir: Optional[str] = None,
|
|
36
|
-
) -> "DriverLogger":
|
|
37
|
-
"""
|
|
38
|
-
Initialize the global driver logger with zero configuration.
|
|
39
|
-
|
|
40
|
-
Args:
|
|
41
|
-
parser_id: Unique parser identifier
|
|
42
|
-
parser_name: Human-readable parser name
|
|
43
|
-
log_level: Logging level (DEBUG, INFO, WARNING, ERROR, CRITICAL)
|
|
44
|
-
enable_console: Enable console output
|
|
45
|
-
enable_websocket: Enable WebSocket streaming
|
|
46
|
-
|
|
47
|
-
Returns:
|
|
48
|
-
Configured DriverLogger instance
|
|
49
|
-
"""
|
|
50
|
-
global _driver_logger
|
|
51
|
-
|
|
52
|
-
# Map string log levels to SDK severity
|
|
53
|
-
level_map = {
|
|
54
|
-
"TRACE": SDKSeverity.TRACE,
|
|
55
|
-
"DEBUG": SDKSeverity.DEBUG,
|
|
56
|
-
"INFO": SDKSeverity.INFO,
|
|
57
|
-
"WARNING": SDKSeverity.WARNING,
|
|
58
|
-
"ERROR": SDKSeverity.ERROR,
|
|
59
|
-
"CRITICAL": SDKSeverity.CRITICAL,
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
sdk_level = level_map.get(log_level.upper(), SDKSeverity.INFO)
|
|
63
|
-
|
|
64
|
-
# Use SDK logger with correct parameters
|
|
65
|
-
dev_logger = initialize_development_logger(
|
|
66
|
-
session_id=f"{parser_id}_session",
|
|
67
|
-
log_level=sdk_level,
|
|
68
|
-
enable_console=enable_console,
|
|
69
|
-
enable_websocket=enable_websocket,
|
|
70
|
-
)
|
|
71
|
-
|
|
72
|
-
# Set layer context for Driver
|
|
73
|
-
dev_logger.set_layer_context("UnrealOn_Driver")
|
|
74
|
-
|
|
75
|
-
# 🔥 ADD FILE LOGGING SUPPORT
|
|
76
|
-
file_logger = None
|
|
77
|
-
if system_dir:
|
|
78
|
-
log_file_path = Path(system_dir) / "logs" / "parser.log"
|
|
79
|
-
log_file_path.parent.mkdir(parents=True, exist_ok=True)
|
|
80
|
-
|
|
81
|
-
# Create standard Python file logger
|
|
82
|
-
file_logger = logging.getLogger(f"driver_file_{parser_id}")
|
|
83
|
-
file_logger.setLevel(getattr(logging, log_level.upper(), logging.INFO))
|
|
84
|
-
|
|
85
|
-
# Remove existing handlers to avoid duplicates
|
|
86
|
-
for handler in file_logger.handlers[:]:
|
|
87
|
-
file_logger.removeHandler(handler)
|
|
88
|
-
|
|
89
|
-
# Add file handler
|
|
90
|
-
file_handler = logging.FileHandler(log_file_path)
|
|
91
|
-
formatter = logging.Formatter(
|
|
92
|
-
'%(asctime)s | DRIVER | %(levelname)s | %(message)s',
|
|
93
|
-
datefmt='%H:%M:%S'
|
|
94
|
-
)
|
|
95
|
-
file_handler.setFormatter(formatter)
|
|
96
|
-
file_logger.addHandler(file_handler)
|
|
97
|
-
file_logger.propagate = False # Prevent double logging
|
|
98
|
-
|
|
99
|
-
_driver_logger = DriverLogger(dev_logger, parser_id, parser_name, file_logger)
|
|
100
|
-
return _driver_logger
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
def get_driver_logger() -> Optional["DriverLogger"]:
|
|
104
|
-
"""Get the global driver logger instance."""
|
|
105
|
-
return _driver_logger
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
def ensure_driver_logger(
|
|
109
|
-
parser_id: str = "default",
|
|
110
|
-
parser_name: str = "UnrealOn Parser",
|
|
111
|
-
system_dir: Optional[str] = None,
|
|
112
|
-
) -> "DriverLogger":
|
|
113
|
-
"""
|
|
114
|
-
Ensure driver logger exists, create if needed (zero-configuration).
|
|
115
|
-
|
|
116
|
-
Args:
|
|
117
|
-
parser_id: Fallback parser ID if none exists
|
|
118
|
-
parser_name: Fallback parser name if none exists
|
|
119
|
-
|
|
120
|
-
Returns:
|
|
121
|
-
DriverLogger instance
|
|
122
|
-
"""
|
|
123
|
-
global _driver_logger
|
|
124
|
-
if not _driver_logger:
|
|
125
|
-
_driver_logger = initialize_driver_logger(
|
|
126
|
-
parser_id=parser_id, parser_name=parser_name, system_dir=system_dir
|
|
127
|
-
)
|
|
128
|
-
return _driver_logger
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
class DriverLogger:
|
|
132
|
-
"""
|
|
133
|
-
Specialized logger for Driver v3.0 operations.
|
|
134
|
-
|
|
135
|
-
Zero-configuration logging with enterprise features:
|
|
136
|
-
- Browser automation events
|
|
137
|
-
- Data extraction operations
|
|
138
|
-
- Service lifecycle tracking
|
|
139
|
-
- Performance metrics
|
|
140
|
-
- Real-time WebSocket streaming (optional)
|
|
141
|
-
- Structured logging with Pydantic v2
|
|
142
|
-
"""
|
|
143
|
-
|
|
144
|
-
def __init__(
|
|
145
|
-
self,
|
|
146
|
-
dev_logger: DevelopmentLogger,
|
|
147
|
-
parser_id: str = "unknown",
|
|
148
|
-
parser_name: str = "UnrealOn Parser",
|
|
149
|
-
file_logger: Optional[logging.Logger] = None,
|
|
150
|
-
):
|
|
151
|
-
"""Initialize driver logger with SDK development logger and optional file logger."""
|
|
152
|
-
self._dev_logger = dev_logger
|
|
153
|
-
self._file_logger = file_logger
|
|
154
|
-
self.parser_id = parser_id
|
|
155
|
-
self.parser_name = parser_name
|
|
156
|
-
|
|
157
|
-
# Set component context
|
|
158
|
-
self._dev_logger.set_component_context(f"Parser[{parser_id}]")
|
|
159
|
-
|
|
160
|
-
# Log initialization
|
|
161
|
-
self.info(f"🚀 DriverLogger initialized: {parser_name}")
|
|
162
|
-
|
|
163
|
-
# ==========================================
|
|
164
|
-
# BASIC LOGGING METHODS
|
|
165
|
-
# ==========================================
|
|
166
|
-
|
|
167
|
-
def debug(self, message: str, details: Optional[Dict[str, Any]] = None) -> None:
|
|
168
|
-
"""Log debug message."""
|
|
169
|
-
self._dev_logger.log_debug(
|
|
170
|
-
SDKEventType.COMPONENT_TESTED,
|
|
171
|
-
message,
|
|
172
|
-
context=self._create_context(details),
|
|
173
|
-
)
|
|
174
|
-
# 🔥 Also log to file if file logger exists
|
|
175
|
-
if self._file_logger:
|
|
176
|
-
self._file_logger.debug(message)
|
|
177
|
-
|
|
178
|
-
def info(self, message: str, details: Optional[Dict[str, Any]] = None) -> None:
|
|
179
|
-
"""Log info message."""
|
|
180
|
-
self._dev_logger.log_info(
|
|
181
|
-
SDKEventType.COMMAND_COMPLETED,
|
|
182
|
-
message,
|
|
183
|
-
context=self._create_context(details),
|
|
184
|
-
)
|
|
185
|
-
# 🔥 Also log to file if file logger exists
|
|
186
|
-
if self._file_logger:
|
|
187
|
-
self._file_logger.info(message)
|
|
188
|
-
|
|
189
|
-
def warning(self, message: str, details: Optional[Dict[str, Any]] = None) -> None:
|
|
190
|
-
"""Log warning message."""
|
|
191
|
-
self._dev_logger.log_warning(
|
|
192
|
-
SDKEventType.PERFORMANCE_THRESHOLD_EXCEEDED,
|
|
193
|
-
message,
|
|
194
|
-
context=self._create_context(details),
|
|
195
|
-
)
|
|
196
|
-
# 🔥 Also log to file if file logger exists
|
|
197
|
-
if self._file_logger:
|
|
198
|
-
self._file_logger.warning(message)
|
|
199
|
-
|
|
200
|
-
def error(
|
|
201
|
-
self,
|
|
202
|
-
message: str,
|
|
203
|
-
error: Optional[Exception] = None,
|
|
204
|
-
details: Optional[Dict[str, Any]] = None,
|
|
205
|
-
) -> None:
|
|
206
|
-
"""Log error message with optional exception."""
|
|
207
|
-
context = self._create_context(details)
|
|
208
|
-
if error:
|
|
209
|
-
context.metadata["error_type"] = type(error).__name__
|
|
210
|
-
context.metadata["error_message"] = str(error)
|
|
211
|
-
|
|
212
|
-
self._dev_logger.log_error(
|
|
213
|
-
SDKEventType.COMMAND_FAILED, message, context=context
|
|
214
|
-
)
|
|
215
|
-
# 🔥 Also log to file if file logger exists
|
|
216
|
-
if self._file_logger:
|
|
217
|
-
error_msg = f"{message} - {error}" if error else message
|
|
218
|
-
self._file_logger.error(error_msg)
|
|
219
|
-
|
|
220
|
-
def critical(
|
|
221
|
-
self,
|
|
222
|
-
message: str,
|
|
223
|
-
error: Optional[Exception] = None,
|
|
224
|
-
details: Optional[Dict[str, Any]] = None,
|
|
225
|
-
) -> None:
|
|
226
|
-
"""Log critical message."""
|
|
227
|
-
context = self._create_context(details)
|
|
228
|
-
if error:
|
|
229
|
-
context.metadata["error_type"] = type(error).__name__
|
|
230
|
-
context.metadata["error_message"] = str(error)
|
|
231
|
-
|
|
232
|
-
self._dev_logger.log_critical(SDKEventType.SDK_ERROR, message, context=context)
|
|
233
|
-
|
|
234
|
-
# ==========================================
|
|
235
|
-
# DRIVER-SPECIFIC LOGGING METHODS
|
|
236
|
-
# ==========================================
|
|
237
|
-
|
|
238
|
-
def log_parser_start(
|
|
239
|
-
self, mode: str = "test", details: Optional[Dict[str, Any]] = None
|
|
240
|
-
) -> None:
|
|
241
|
-
"""Log parser execution start."""
|
|
242
|
-
context = self._create_context(details)
|
|
243
|
-
context.metadata["execution_mode"] = mode
|
|
244
|
-
context.metadata["parser_name"] = self.parser_name
|
|
245
|
-
|
|
246
|
-
self._dev_logger.log_info(
|
|
247
|
-
SDKEventType.COMMAND_RECEIVED,
|
|
248
|
-
f"🎯 Parser started in {mode} mode",
|
|
249
|
-
context=context,
|
|
250
|
-
)
|
|
251
|
-
|
|
252
|
-
def log_parser_success(
|
|
253
|
-
self,
|
|
254
|
-
result_count: int = 0,
|
|
255
|
-
duration: Optional[float] = None,
|
|
256
|
-
details: Optional[Dict[str, Any]] = None,
|
|
257
|
-
) -> None:
|
|
258
|
-
"""Log successful parser completion."""
|
|
259
|
-
context = self._create_context(details)
|
|
260
|
-
context.metadata["result_count"] = result_count
|
|
261
|
-
if duration:
|
|
262
|
-
context.metadata["duration_seconds"] = duration
|
|
263
|
-
|
|
264
|
-
self._dev_logger.log_info(
|
|
265
|
-
SDKEventType.COMMAND_COMPLETED,
|
|
266
|
-
f"✅ Parser completed successfully - {result_count} items processed",
|
|
267
|
-
context=context,
|
|
268
|
-
)
|
|
269
|
-
|
|
270
|
-
def log_parser_error(
|
|
271
|
-
self, error: Exception, details: Optional[Dict[str, Any]] = None
|
|
272
|
-
) -> None:
|
|
273
|
-
"""Log parser execution error."""
|
|
274
|
-
context = self._create_context(details)
|
|
275
|
-
context.metadata["error_type"] = type(error).__name__
|
|
276
|
-
context.metadata["error_message"] = str(error)
|
|
277
|
-
|
|
278
|
-
self._dev_logger.log_error(
|
|
279
|
-
SDKEventType.COMMAND_FAILED,
|
|
280
|
-
f"❌ Parser execution failed: {error}",
|
|
281
|
-
context=context,
|
|
282
|
-
)
|
|
283
|
-
|
|
284
|
-
def log_browser_operation(
|
|
285
|
-
self,
|
|
286
|
-
operation: str,
|
|
287
|
-
url: str = "",
|
|
288
|
-
success: bool = True,
|
|
289
|
-
details: Optional[Dict[str, Any]] = None,
|
|
290
|
-
) -> None:
|
|
291
|
-
"""Log browser automation operation."""
|
|
292
|
-
context = self._create_context(details)
|
|
293
|
-
context.metadata["operation"] = operation
|
|
294
|
-
context.metadata["url"] = url
|
|
295
|
-
context.metadata["success"] = success
|
|
296
|
-
|
|
297
|
-
status = "✅" if success else "❌"
|
|
298
|
-
message = f"{status} Browser {operation}"
|
|
299
|
-
if url:
|
|
300
|
-
message += f" - {url}"
|
|
301
|
-
|
|
302
|
-
event_type = (
|
|
303
|
-
SDKEventType.COMMAND_COMPLETED if success else SDKEventType.COMMAND_FAILED
|
|
304
|
-
)
|
|
305
|
-
|
|
306
|
-
if success:
|
|
307
|
-
self._dev_logger.log_info(event_type, message, context=context)
|
|
308
|
-
else:
|
|
309
|
-
self._dev_logger.log_error(event_type, message, context=context)
|
|
310
|
-
|
|
311
|
-
def log_data_extraction(
|
|
312
|
-
self,
|
|
313
|
-
selector: str,
|
|
314
|
-
items_count: int,
|
|
315
|
-
success: bool = True,
|
|
316
|
-
details: Optional[Dict[str, Any]] = None,
|
|
317
|
-
) -> None:
|
|
318
|
-
"""Log data extraction operation."""
|
|
319
|
-
context = self._create_context(details)
|
|
320
|
-
context.metadata["selector"] = selector
|
|
321
|
-
context.metadata["items_extracted"] = items_count
|
|
322
|
-
context.metadata["success"] = success
|
|
323
|
-
|
|
324
|
-
status = "✅" if success else "❌"
|
|
325
|
-
message = f"{status} Data extraction - {items_count} items from '{selector}'"
|
|
326
|
-
|
|
327
|
-
event_type = (
|
|
328
|
-
SDKEventType.COMMAND_COMPLETED if success else SDKEventType.COMMAND_FAILED
|
|
329
|
-
)
|
|
330
|
-
|
|
331
|
-
if success:
|
|
332
|
-
self._dev_logger.log_info(event_type, message, context=context)
|
|
333
|
-
else:
|
|
334
|
-
self._dev_logger.log_error(event_type, message, context=context)
|
|
335
|
-
|
|
336
|
-
def log_service_operation(
|
|
337
|
-
self,
|
|
338
|
-
service_name: str,
|
|
339
|
-
operation: str,
|
|
340
|
-
success: bool = True,
|
|
341
|
-
duration: Optional[float] = None,
|
|
342
|
-
details: Optional[Dict[str, Any]] = None,
|
|
343
|
-
) -> None:
|
|
344
|
-
"""Log service operation (browser, llm, websocket, etc.)."""
|
|
345
|
-
context = self._create_context(details)
|
|
346
|
-
context.metadata["service"] = service_name
|
|
347
|
-
context.metadata["operation"] = operation
|
|
348
|
-
context.metadata["success"] = success
|
|
349
|
-
if duration:
|
|
350
|
-
context.metadata["duration_seconds"] = duration
|
|
351
|
-
|
|
352
|
-
status = "✅" if success else "❌"
|
|
353
|
-
message = f"{status} {service_name.title()} {operation}"
|
|
354
|
-
if duration:
|
|
355
|
-
message += f" ({duration:.3f}s)"
|
|
356
|
-
|
|
357
|
-
event_type = (
|
|
358
|
-
SDKEventType.COMMAND_COMPLETED if success else SDKEventType.COMMAND_FAILED
|
|
359
|
-
)
|
|
360
|
-
|
|
361
|
-
if success:
|
|
362
|
-
self._dev_logger.log_info(event_type, message, context=context)
|
|
363
|
-
else:
|
|
364
|
-
self._dev_logger.log_error(event_type, message, context=context)
|
|
365
|
-
|
|
366
|
-
def log_llm_operation(
|
|
367
|
-
self,
|
|
368
|
-
operation: str,
|
|
369
|
-
tokens: int = 0,
|
|
370
|
-
cost: float = 0.0,
|
|
371
|
-
success: bool = True,
|
|
372
|
-
details: Optional[Dict[str, Any]] = None,
|
|
373
|
-
) -> None:
|
|
374
|
-
"""Log LLM operation with cost tracking."""
|
|
375
|
-
context = self._create_context(details)
|
|
376
|
-
context.metadata["llm_operation"] = operation
|
|
377
|
-
context.metadata["tokens_used"] = tokens
|
|
378
|
-
context.metadata["cost_usd"] = cost
|
|
379
|
-
context.metadata["success"] = success
|
|
380
|
-
|
|
381
|
-
status = "✅" if success else "❌"
|
|
382
|
-
message = f"{status} LLM {operation}"
|
|
383
|
-
if tokens > 0:
|
|
384
|
-
message += f" - {tokens} tokens"
|
|
385
|
-
if cost > 0:
|
|
386
|
-
message += f" (${cost:.4f})"
|
|
387
|
-
|
|
388
|
-
event_type = (
|
|
389
|
-
SDKEventType.COMMAND_COMPLETED if success else SDKEventType.COMMAND_FAILED
|
|
390
|
-
)
|
|
391
|
-
|
|
392
|
-
if success:
|
|
393
|
-
self._dev_logger.log_info(event_type, message, context=context)
|
|
394
|
-
else:
|
|
395
|
-
self._dev_logger.log_error(event_type, message, context=context)
|
|
396
|
-
|
|
397
|
-
# ==========================================
|
|
398
|
-
# PERFORMANCE & METRICS
|
|
399
|
-
# ==========================================
|
|
400
|
-
|
|
401
|
-
def start_operation(self, operation_name: str, description: str = "") -> str:
|
|
402
|
-
"""Start tracking operation performance."""
|
|
403
|
-
import time
|
|
404
|
-
import uuid
|
|
405
|
-
|
|
406
|
-
# Generate operation ID and store start time
|
|
407
|
-
operation_id = f"{operation_name}_{uuid.uuid4().hex[:8]}"
|
|
408
|
-
if not hasattr(self, '_operation_times'):
|
|
409
|
-
self._operation_times = {}
|
|
410
|
-
self._operation_times[operation_id] = time.time()
|
|
411
|
-
|
|
412
|
-
# Start operation in SDK logger
|
|
413
|
-
desc = description or f"Starting {operation_name} operation"
|
|
414
|
-
self._dev_logger.start_operation(operation_id, desc)
|
|
415
|
-
|
|
416
|
-
return operation_id
|
|
417
|
-
|
|
418
|
-
def end_operation(
|
|
419
|
-
self,
|
|
420
|
-
operation_id: str,
|
|
421
|
-
success: bool = True,
|
|
422
|
-
result_data: Optional[Dict[str, Any]] = None,
|
|
423
|
-
) -> float:
|
|
424
|
-
"""End operation tracking and return duration."""
|
|
425
|
-
import time
|
|
426
|
-
# Calculate duration manually since complete_operation returns None
|
|
427
|
-
if operation_id in getattr(self, '_operation_times', {}):
|
|
428
|
-
start_time = self._operation_times.pop(operation_id)
|
|
429
|
-
duration = time.time() - start_time
|
|
430
|
-
else:
|
|
431
|
-
duration = 0.0
|
|
432
|
-
|
|
433
|
-
# Complete the operation in SDK logger
|
|
434
|
-
description = f"Operation {operation_id} {'completed' if success else 'failed'}"
|
|
435
|
-
self._dev_logger.complete_operation(operation_id, description, success)
|
|
436
|
-
|
|
437
|
-
return duration
|
|
438
|
-
|
|
439
|
-
def log_performance_metric(
|
|
440
|
-
self,
|
|
441
|
-
metric_name: str,
|
|
442
|
-
value: float,
|
|
443
|
-
unit: str = "",
|
|
444
|
-
details: Optional[Dict[str, Any]] = None,
|
|
445
|
-
) -> None:
|
|
446
|
-
"""Log performance metric."""
|
|
447
|
-
context = self._create_context(details)
|
|
448
|
-
context.metadata["metric_name"] = metric_name
|
|
449
|
-
context.metadata["metric_value"] = value
|
|
450
|
-
context.metadata["metric_unit"] = unit
|
|
451
|
-
|
|
452
|
-
message = f"📊 {metric_name}: {value}"
|
|
453
|
-
if unit:
|
|
454
|
-
message += f" {unit}"
|
|
455
|
-
|
|
456
|
-
self._dev_logger.log_info(
|
|
457
|
-
SDKEventType.PERFORMANCE_METRIC_COLLECTED, message, context=context
|
|
458
|
-
)
|
|
459
|
-
|
|
460
|
-
# ==========================================
|
|
461
|
-
# CONTEXT & UTILITIES
|
|
462
|
-
# ==========================================
|
|
463
|
-
|
|
464
|
-
def _create_context(self, details: Optional[Dict[str, Any]] = None) -> SDKContext:
|
|
465
|
-
"""Create SDK context for logging."""
|
|
466
|
-
metadata = {
|
|
467
|
-
"parser_id": self.parser_id,
|
|
468
|
-
"parser_name": self.parser_name,
|
|
469
|
-
"timestamp": datetime.now(timezone.utc).isoformat(),
|
|
470
|
-
}
|
|
471
|
-
|
|
472
|
-
if details:
|
|
473
|
-
metadata.update(details)
|
|
474
|
-
|
|
475
|
-
return SDKContext(
|
|
476
|
-
parser_id=self.parser_id,
|
|
477
|
-
component_name=f"Parser[{self.parser_id}]",
|
|
478
|
-
layer_name="UnrealOn_Driver",
|
|
479
|
-
metadata=metadata,
|
|
480
|
-
)
|
|
481
|
-
|
|
482
|
-
def set_parser_context(self, parser_id: str, parser_name: str) -> None:
|
|
483
|
-
"""Update parser context."""
|
|
484
|
-
self.parser_id = parser_id
|
|
485
|
-
self.parser_name = parser_name
|
|
486
|
-
self._dev_logger.set_component_context(f"Parser[{parser_id}]")
|
|
487
|
-
|
|
488
|
-
def health_check(self) -> Dict[str, Any]:
|
|
489
|
-
"""Check logger health."""
|
|
490
|
-
return {
|
|
491
|
-
"status": "healthy" if self._dev_logger else "unhealthy",
|
|
492
|
-
"parser_id": self.parser_id,
|
|
493
|
-
"parser_name": self.parser_name,
|
|
494
|
-
"session_id": self._dev_logger.session_id if self._dev_logger else None,
|
|
495
|
-
"log_level": self._dev_logger.log_level.value if self._dev_logger else None,
|
|
496
|
-
"console_enabled": (
|
|
497
|
-
self._dev_logger.enable_console if self._dev_logger else False
|
|
498
|
-
),
|
|
499
|
-
"websocket_enabled": (
|
|
500
|
-
self._dev_logger.enable_websocket if self._dev_logger else False
|
|
501
|
-
),
|
|
502
|
-
}
|
|
503
|
-
|
|
504
|
-
async def cleanup(self) -> None:
|
|
505
|
-
"""Clean up logger resources."""
|
|
506
|
-
if self._dev_logger:
|
|
507
|
-
await self._dev_logger.shutdown()
|
|
508
|
-
# Note: Don't log after shutdown
|
|
509
|
-
self.info("🏁 DriverLogger cleanup completed")
|
|
510
|
-
|
|
511
|
-
def __repr__(self) -> str:
|
|
512
|
-
return f"<DriverLogger(parser_id={self.parser_id}, parser_name={self.parser_name})>"
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Service layer for UnrealOn Driver v3.0
|
|
3
|
-
|
|
4
|
-
Zero-configuration services with intelligent automation.
|
|
5
|
-
"""
|
|
6
|
-
|
|
7
|
-
from .browser_service import BrowserService
|
|
8
|
-
from .llm import LLMService, BrowserLLMService, BrowserLLMConfig, ExtractionResult
|
|
9
|
-
from .websocket_service import WebSocketService
|
|
10
|
-
from .logger_service import LoggerService
|
|
11
|
-
from .metrics_service import MetricsService
|
|
12
|
-
from .scheduler_service import SchedulerService
|
|
13
|
-
|
|
14
|
-
__all__ = [
|
|
15
|
-
"BrowserService",
|
|
16
|
-
"LLMService",
|
|
17
|
-
"WebSocketService",
|
|
18
|
-
"LoggerService",
|
|
19
|
-
"MetricsService",
|
|
20
|
-
"SchedulerService",
|
|
21
|
-
"BrowserLLMService",
|
|
22
|
-
"BrowserLLMConfig",
|
|
23
|
-
"ExtractionResult",
|
|
24
|
-
]
|