|
1 | 1 | # SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES |
2 | | -# Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. |
| 2 | +# Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. |
3 | 3 | # SPDX-License-Identifier: Apache-2.0 |
4 | 4 | # |
5 | 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
|
14 | 14 | # See the License for the specific language governing permissions and |
15 | 15 | # limitations under the License. |
16 | 16 |
|
17 | | -import logging |
18 | | -import logging.config |
19 | | - |
20 | | -from .cli import CloudAICLI |
21 | | -from .handlers import handle_dry_run_and_run, handle_generate_report, handle_install_and_uninstall |
22 | | - |
23 | | - |
24 | | -def setup_logging(log_file: str, log_level: str) -> None: |
25 | | - """ |
26 | | - Configure logging for the application. |
27 | | -
|
28 | | - Args: |
29 | | - log_level (str): The logging level (e.g., DEBUG, INFO). |
30 | | - log_file (str): The name of the log file. |
31 | | - """ |
32 | | - numeric_level = getattr(logging, log_level.upper(), None) |
33 | | - if not isinstance(numeric_level, int): |
34 | | - raise ValueError(f"Invalid log level: {log_level}") |
35 | | - |
36 | | - LOGGING_CONFIG = { |
37 | | - "version": 1, |
38 | | - "disable_existing_loggers": True, |
39 | | - "formatters": { |
40 | | - "standard": {"format": "%(asctime)s - %(levelname)s - %(message)s"}, |
41 | | - "short": {"format": "[%(levelname)s] %(message)s"}, |
42 | | - }, |
43 | | - "handlers": { |
44 | | - "default": { |
45 | | - "level": log_level.upper(), |
46 | | - "formatter": "short", |
47 | | - "class": "logging.StreamHandler", |
48 | | - "stream": "ext://sys.stdout", |
49 | | - }, |
50 | | - "debug_file": { |
51 | | - "level": "DEBUG", |
52 | | - "formatter": "standard", |
53 | | - "class": "logging.FileHandler", |
54 | | - "filename": log_file, |
55 | | - "mode": "w", |
56 | | - }, |
57 | | - }, |
58 | | - "loggers": { |
59 | | - "": { |
60 | | - "handlers": ["default", "debug_file"], |
61 | | - "level": "DEBUG", |
62 | | - "propagate": False, |
63 | | - }, |
64 | | - }, |
65 | | - } |
66 | | - logging.config.dictConfig(LOGGING_CONFIG) |
67 | | - |
| 17 | +from .cli import main, setup_logging |
68 | 18 |
|
69 | 19 | __all__ = [ |
70 | | - "CloudAICLI", |
71 | | - "handle_dry_run_and_run", |
72 | | - "handle_generate_report", |
73 | | - "handle_install_and_uninstall", |
| 20 | + "main", |
74 | 21 | "setup_logging", |
75 | 22 | ] |
0 commit comments