This repository was archived by the owner on Jan 16, 2024. It is now read-only.
  
  
  
  
  
Description
If may happen the logging via systemd-cat or even logger is not available. The contextualization should fallback to the log on its own with a syslog line format. Also, the logging function should have neutral return code no matter if the function succeeds or fails.
  
  
    
        
          |  | logger -t "${SYSLOG_TAG}" \ | 
        
          |  | -p "${SYSLOG_FACILITY}.${1}" \ | 
        
          |  | "${2}" 2>/dev/null | 
        
          |  |  | 
        
          |  | elif [ "${1}" != 'debug' ]; then | 
        
          |  | local _txt="$(date "+%b %d %T") $(hostname -s) ${SYSLOG_TAG}: ${2}" | 
        
          |  |  | 
        
          |  | local _log=/var/log/messages | 
        
          |  | if [ -f /var/log/syslog ]; then | 
        
          |  | _log=/var/log/syslog | 
        
          |  | fi | 
        
          |  |  | 
        
          |  | echo "${_txt}" >>"${_log}" 2>/dev/null |