Refine log messages

This commit is contained in:
Alexander Zobnin
2020-08-25 13:36:36 +03:00
parent 804cc1cac6
commit d6b8992433
3 changed files with 8 additions and 10 deletions

View File

@@ -80,7 +80,7 @@ func (ds *ZabbixDatasource) CheckHealth(ctx context.Context, req *backend.CheckH
if err != nil {
res.Status = backend.HealthStatusError
res.Message = err.Error()
ds.logger.Error("Error connecting zabbix", "err", err)
ds.logger.Error("Error connecting Zabbix server", "err", err)
return res, nil
}

View File

@@ -37,7 +37,7 @@ func (ds *ZabbixDatasourceInstance) ZabbixQuery(ctx context.Context, apiReq *Zab
}
if _, ok := CachedMethods[apiReq.Method]; ok {
ds.logger.Debug("Write result to cache", "method", apiReq.Method)
ds.logger.Debug("Writing result to cache", "method", apiReq.Method)
ds.queryCache.SetAPIRequest(apiReq, resultJson)
}
} else {
@@ -80,14 +80,12 @@ func (ds *ZabbixDatasourceInstance) TestConnection(ctx context.Context) (string,
}
resultByte, _ := response.MarshalJSON()
ds.logger.Debug("TestConnection", "result", string(resultByte))
return string(resultByte), nil
}
// ZabbixRequest checks authentication and makes a request to the Zabbix API
func (ds *ZabbixDatasourceInstance) ZabbixRequest(ctx context.Context, method string, params ZabbixAPIParams) (*simplejson.Json, error) {
ds.logger.Debug("Invoke Zabbix API request", "ds", ds.dsInfo.Name, "method", method)
ds.logger.Debug("Zabbix API request", "datasource", ds.dsInfo.Name, "method", method)
var result *simplejson.Json
var err error
@@ -449,7 +447,7 @@ func (ds *ZabbixDatasourceInstance) getHistotyOrTrend(ctx context.Context, query
history := History{}
err = json.Unmarshal(pointJSON, &history)
if err != nil {
ds.logger.Warn(fmt.Sprintf("Could not map Zabbix response to History: %s", err.Error()))
ds.logger.Error("Error handling history response", "error", err.Error())
} else {
allHistory = append(allHistory, history...)
}

View File

@@ -20,7 +20,7 @@ func main() {
ds := Init(pluginLogger, mux)
httpResourceHandler := httpadapter.New(mux)
pluginLogger.Debug("Starting Zabbix backend datasource")
pluginLogger.Debug("Starting Zabbix datasource")
err := backend.Serve(backend.ServeOpts{
CallResourceHandler: httpResourceHandler,
@@ -28,7 +28,7 @@ func main() {
CheckHealthHandler: ds,
})
if err != nil {
pluginLogger.Error(err.Error())
pluginLogger.Error("Error starting Zabbix datasource", "error", err.Error())
}
}
@@ -36,9 +36,9 @@ func Init(logger log.Logger, mux *http.ServeMux) *datasource.ZabbixDatasource {
variableName := "GFX_ZABBIX_DATA_PATH"
path, exist := os.LookupEnv(variableName)
if !exist {
logger.Error("could not read environment variable", variableName)
logger.Debug("Could not read environment variable", variableName)
} else {
logger.Debug("environment variable for storage found", "variable", variableName, "value", path)
logger.Debug("Environment variable for storage found", "variable", variableName, "value", path)
}
ds := datasource.NewZabbixDatasource()