func GetTimeSync() (bool, float64) {
    DebugLogger.Println("Syncing time with Coralogix server...")

    client := &http.Client{
        Timeout: time.Duration(time.Duration(TimeDelayTimeout) * time.Second),
    }

    response, err := client.Get(TimeDeltaUrl)

    if err != nil {
        DebugLogger.Println("Can't execute HTTP request:", err)
        return false, 0
    }

    if response.StatusCode == 200 {
        response, _ := ioutil.ReadAll(response.Body)
        ServerTime, err := strconv.ParseFloat(string(response), 64)

        if err != nil {
            DebugLogger.Println("Can't parse HTTP response:", err)
            return false, 0
        }

        ServerTime = ServerTime / 1E4
        LocalTime := float64(time.Now().Unix() * 1E3)
        TimeDelta := ServerTime - LocalTime

        return true, TimeDelta
    }

    DebugLogger.Println("Can't get server time")
    return false, 0
}
// GetTimeSync synchronize logs time with Coralogix servers time
GetTimeSync synchronize logs time with Coralogix servers time
// GetTimeSync synchronize logs time with Coralogix servers time
func GetTimeSync() (bool, float64) {
    DebugLogger.Println("Syncing time with Coralogix server...")
    client := &http.Client{
        Timeout: time.Duration(time.Duration(TimeDelayTimeout) * time.Second),
    }
    response, err := client.Get(TimeDeltaUrl)
    if err != nil {
        DebugLogger.Println("Can't execute HTTP request:", err)
        return false, 0
    }
    if response.StatusCode == 200 {
        response, _ := ioutil.ReadAll(response.Body)
        ServerTime, err := strconv.ParseFloat(string(response), 64)
        if err != nil {
            DebugLogger.Println("Can't parse HTTP response:", err)
            return false, 0
        }
        ServerTime = ServerTime / 1E4
        LocalTime := float64(time.Now().Unix() * 1E3)
        TimeDelta := ServerTime - LocalTime
        return true, TimeDelta
    }
    DebugLogger.Println("Can't get server time")
    return false, 0
}
func GetTimeSync ( ) ( bool , float64 ) { DebugLogger . Println ( " " ) client := & http . Client { Timeout : time . Duration ( time . Duration ( TimeDelayTimeout ) * time . Second ) , } response , err := client . Get ( TimeDeltaUrl ) if err != nil { DebugLogger . Println ( " " , err ) return false , 0 } if response . StatusCode == 200 { response , _ := ioutil . ReadAll ( response . Body ) ServerTime , err := strconv . ParseFloat ( string ( response ) , 64 ) if err != nil { DebugLogger . Println ( " " , err ) return false , 0 } ServerTime = ServerTime / 1E4 LocalTime := float64 ( time . Now ( ) . Unix ( ) * 1E3 ) TimeDelta := ServerTime - LocalTime return true , TimeDelta } DebugLogger . Println ( " " ) return false , 0 }
GetTimeSync synchronize logs time with Coralogix servers time
GetTimeSync synchronize logs time with Coralogix servers time