Skip to content

Commit 0b69cb7

Browse files
authored
remove logging
1 parent 81df26f commit 0b69cb7

File tree

1 file changed

+4
-73
lines changed

1 file changed

+4
-73
lines changed

builder/frameworks/arduino.py

Lines changed: 4 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
import sys
2929
import shutil
3030
import hashlib
31-
import logging
3231
import threading
3332
from contextlib import suppress
3433
from os.path import join, exists, isabs, splitdrive, commonpath, relpath
@@ -52,28 +51,6 @@
5251
"esp-idf-size": ">=1.6.1"
5352
}
5453

55-
56-
def setup_logging():
57-
"""Setup logging with optional file output"""
58-
handlers = [logging.StreamHandler()]
59-
60-
# Only add file handler if writable and not disabled
61-
log_file = os.environ.get('ARDUINO_FRAMEWORK_LOG_FILE')
62-
if log_file:
63-
with suppress(OSError, PermissionError):
64-
handlers.append(logging.FileHandler(log_file))
65-
66-
logging.basicConfig(
67-
level=logging.INFO,
68-
format='%(asctime)s - %(levelname)s - %(message)s',
69-
handlers=handlers
70-
)
71-
72-
73-
# Only setup logging if enabled via environment variable
74-
if os.environ.get('ARDUINO_FRAMEWORK_ENABLE_LOGGING'):
75-
setup_logging()
76-
7754
# Constants for better performance
7855
UNICORE_FLAGS = {
7956
"CORE32SOLO1",
@@ -118,12 +95,6 @@ def get_platform_default_threshold(mcu):
11895

11996
default_value = platform_defaults.get(mcu, 31600)
12097

121-
# Debug output only in verbose mode
122-
if logging.getLogger().isEnabledFor(logging.DEBUG):
123-
logging.debug(
124-
f"Max. possible platform default threshold for {mcu}: "
125-
f"{default_value}")
126-
12798
return default_value
12899

129100

@@ -182,7 +153,7 @@ def validate_threshold(threshold, mcu):
182153
print("*** Consider using higher values for maximum performance ***")
183154

184155
if original_threshold != threshold:
185-
logging.warning(f"Threshold adjusted from {original_threshold} to "
156+
print(f"Threshold adjusted from {original_threshold} to "
186157
f"max. possible value {threshold} for {mcu}")
187158

188159
return threshold
@@ -413,7 +384,6 @@ def safe_delete_file(file_path: Union[str, Path],
413384
try:
414385
# Check existence
415386
if not file_path.exists():
416-
logging.warning(f"File does not exist: {file_path}")
417387
return False
418388

419389
# Remove write protection if necessary
@@ -422,14 +392,11 @@ def safe_delete_file(file_path: Union[str, Path],
422392

423393
# Delete file
424394
file_path.unlink()
425-
logging.info(f"File deleted: {file_path}")
426395
return True
427396

428397
except PermissionError:
429-
logging.error(f"No permission to delete: {file_path}")
430398
return False
431399
except Exception as e:
432-
logging.error(f"Error deleting {file_path}: {e}")
433400
return False
434401

435402

@@ -441,15 +408,12 @@ def safe_delete_directory(dir_path: Union[str, Path]) -> bool:
441408

442409
try:
443410
if not dir_path.exists():
444-
logging.warning(f"Directory does not exist: {dir_path}")
445411
return False
446412

447413
shutil.rmtree(dir_path)
448-
logging.info(f"Directory deleted: {dir_path}")
449414
return True
450415

451416
except Exception as e:
452-
logging.error(f"Error deleting {dir_path}: {e}")
453417
return False
454418

455419

@@ -484,7 +448,6 @@ def validate_platformio_path(path: Union[str, Path]) -> bool:
484448
return not any(critical in path_str for critical in critical_paths)
485449

486450
except Exception as e:
487-
logging.error(f"Path validation error: {e}")
488451
return False
489452

490453

@@ -519,23 +482,15 @@ def validate_deletion_path(path: Union[str, Path],
519482
normalized_critical = critical.resolve()
520483
if (normalized_path == normalized_critical or
521484
normalized_critical in normalized_path.parents):
522-
logging.error(f"Critical system path detected: {path}")
523485
return False
524486
except (OSError, ValueError):
525487
# Path comparison failed, reject for safety
526-
logging.error(f"Path comparison failed for: {path}")
527488
return False
528489

529490
# Check against allowed patterns
530491
path_str = str(path)
531492
is_allowed = any(pattern in path_str for pattern in allowed_patterns)
532493

533-
if not is_allowed:
534-
logging.error(f"Path does not match allowed patterns: {path}")
535-
logging.error(f"Allowed patterns: {allowed_patterns}")
536-
else:
537-
logging.info(f"Path validation successful: {path}")
538-
539494
return is_allowed
540495

541496

@@ -545,41 +500,17 @@ def safe_framework_cleanup():
545500

546501
# Framework directory cleanup
547502
if exists(FRAMEWORK_DIR):
548-
logging.info(f"Attempting to validate framework path: "
549-
f"{FRAMEWORK_DIR}")
550-
551503
if validate_platformio_path(FRAMEWORK_DIR):
552-
logging.info(f"Framework path validated successfully: "
553-
f"{FRAMEWORK_DIR}")
554-
555-
if safe_delete_directory(FRAMEWORK_DIR):
556-
print("Framework successfully removed")
557-
else:
504+
if not safe_delete_directory(FRAMEWORK_DIR):
558505
print("Error removing framework")
559506
success = False
560-
else:
561-
logging.error(f"PlatformIO path validation failed: "
562-
f"{FRAMEWORK_DIR}")
563-
success = False
564507

565508
# Framework libs directory cleanup
566509
if exists(FRAMEWORK_LIB_DIR):
567-
logging.info(f"Attempting to validate framework lib path: "
568-
f"{FRAMEWORK_LIB_DIR}")
569-
570510
if validate_platformio_path(FRAMEWORK_LIB_DIR):
571-
logging.info(f"Framework lib path validated successfully: "
572-
f"{FRAMEWORK_LIB_DIR}")
573-
574-
if safe_delete_directory(FRAMEWORK_LIB_DIR):
575-
print("Framework libs successfully removed")
576-
else:
511+
if not safe_delete_directory(FRAMEWORK_LIB_DIR):
577512
print("Error removing framework libs")
578513
success = False
579-
else:
580-
logging.error(f"PlatformIO path validation failed: "
581-
f"{FRAMEWORK_LIB_DIR}")
582-
success = False
583514

584515
return success
585516

@@ -1012,7 +943,7 @@ def get_frameworks_in_current_env():
1012943
call_compile_libs()
1013944
flag_custom_sdkconfig = False
1014945
else:
1015-
logging.error("Framework cleanup failed - installation aborted")
946+
print("Framework cleanup failed - installation aborted")
1016947
sys.exit(1)
1017948

1018949
if flag_custom_sdkconfig and not flag_any_custom_sdkconfig:

0 commit comments

Comments
 (0)