commonutil.application

應用程式輔助函式 / Application helper functions

prepare_syslog(app_name, config_filepath=None)[source]

依據設定檔檔名設定要在 syslog 中顯示的應用程式名稱

Setup syslog according to given application name and configuration file name

Parameters:
  • app_name – 應用程式名稱 / Application name
  • config_filepath=None – 設定檔案路徑 / Path of configuration file
regist_terminate_signal(stop_callable=None, handle_sigterm=False)[source]

註冊終止訊號處理器

Register terminate signal handler call-able

Parameters:
  • stop_callable=None – 發生終止訊號時要執行的函式 / Call-able object or function to invoke on received terminate signal
  • handle_sigterm=False – 是否也要攔截 SIGTERM 訊號 / Handles SIGTERM signal
setup_hourly_rotated_logging_file(base_log_path, logging_level=20, backup_count=120)[source]

設定每小時更換檔名的檔案紀錄方式

Setup logging file with hourly rotating

Parameters:
  • base_log_path – 紀錄檔的路徑 / Path of logging file
  • logging_level=logging.INFO – 紀錄層級 / Logging level
  • backup_count=120 – 要保留的檔案數量 / Number of kept logging file