1
0

add_logging.py 703 B

123456789101112131415161718192021
  1. #ident "@(#)$Format:LocalFoodAI_lanfr144:add_logging.py:%an:%ae:%ad:%cn:%ce:%cd:%H:%D:%N$"
  2. import os
  3. files_to_update = ['scripts/setup_deploy.py', 'docker-compose.yml', 'docker/zabbix/docker-compose.yml']
  4. log_config = '''restart: always
  5. logging:
  6. driver: "json-file"
  7. options:
  8. max-size: "50m"
  9. max-file: "3"'''
  10. for file_path in files_to_update:
  11. if not os.path.exists(file_path):
  12. continue
  13. with open(file_path, 'r', encoding='utf-8') as f:
  14. content = f.read()
  15. if 'logging:' not in content:
  16. content = content.replace('restart: always', log_config)
  17. with open(file_path, 'w', encoding='utf-8') as f:
  18. f.write(content)