mirror of https://github.com/grafana/grafana.git
Fix: Prints should always include new lines (#102795)
* CI: Allow Bench conversion to fail We shouldn't mark PRs and commits as X if they fail to convert logs with Bench. * Fix: Prints should always include new lines * fix: remove unused import
This commit is contained in:
parent
9094c73e33
commit
e1e1d3fd9f
|
|
@ -121,7 +121,7 @@ func CheckDroneTargetBranch() (VersionMode, error) {
|
||||||
if rePRCheckBranch.MatchString(target) {
|
if rePRCheckBranch.MatchString(target) {
|
||||||
return PullRequestMode, nil
|
return PullRequestMode, nil
|
||||||
}
|
}
|
||||||
fmt.Printf("unrecognized target branch: %s, defaulting to %s", target, PullRequestMode)
|
fmt.Printf("unrecognized target branch: %s, defaulting to %s\n", target, PullRequestMode)
|
||||||
return PullRequestMode, nil
|
return PullRequestMode, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package logger
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|
@ -10,40 +11,48 @@ var (
|
||||||
|
|
||||||
func Debug(args ...any) {
|
func Debug(args ...any) {
|
||||||
if debugmode {
|
if debugmode {
|
||||||
fmt.Print(args...)
|
fmt.Println(args...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func Debugf(fmtString string, args ...any) {
|
func Debugf(fmtString string, args ...any) {
|
||||||
if debugmode {
|
if debugmode {
|
||||||
fmt.Printf(fmtString, args...)
|
fmt.Printf(addMissingNewline(fmtString), args...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func Error(args ...any) {
|
func Error(args ...any) {
|
||||||
fmt.Print(args...)
|
fmt.Println(args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func Errorf(fmtString string, args ...any) {
|
func Errorf(fmtString string, args ...any) {
|
||||||
fmt.Printf(fmtString, args...)
|
fmt.Printf(addMissingNewline(fmtString), args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func Info(args ...any) {
|
func Info(args ...any) {
|
||||||
fmt.Print(args...)
|
fmt.Println(args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func Infof(fmtString string, args ...any) {
|
func Infof(fmtString string, args ...any) {
|
||||||
fmt.Printf(fmtString, args...)
|
fmt.Printf(addMissingNewline(fmtString), args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func Warn(args ...any) {
|
func Warn(args ...any) {
|
||||||
fmt.Print(args...)
|
fmt.Println(args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func Warnf(fmtString string, args ...any) {
|
func Warnf(fmtString string, args ...any) {
|
||||||
fmt.Printf(fmtString, args...)
|
fmt.Printf(addMissingNewline(fmtString), args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func SetDebug(value bool) {
|
func SetDebug(value bool) {
|
||||||
debugmode = value
|
debugmode = value
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func addMissingNewline(s string) string {
|
||||||
|
if strings.HasSuffix(s, "\n") {
|
||||||
|
return s
|
||||||
|
}
|
||||||
|
|
||||||
|
return s + "\n"
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ func TestPlaylistConversion(t *testing.T) {
|
||||||
|
|
||||||
out, err := json.MarshalIndent(dst, "", " ")
|
out, err := json.MarshalIndent(dst, "", " ")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
// fmt.Printf("%s", string(out))
|
// t.Logf("%s", string(out))
|
||||||
require.JSONEq(t, `{
|
require.JSONEq(t, `{
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"name": "abc",
|
"name": "abc",
|
||||||
|
|
|
||||||
|
|
@ -279,7 +279,7 @@ func (r *xormRepositoryImpl) Get(ctx context.Context, query annotations.ItemQuer
|
||||||
params = append(params, query.OrgID)
|
params = append(params, query.OrgID)
|
||||||
|
|
||||||
if query.AnnotationID != 0 {
|
if query.AnnotationID != 0 {
|
||||||
// fmt.Print("annotation query")
|
// fmt.Println("annotation query")
|
||||||
sql.WriteString(` AND a.id = ?`)
|
sql.WriteString(` AND a.id = ?`)
|
||||||
params = append(params, query.AnnotationID)
|
params = append(params, query.AnnotationID)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -92,7 +92,7 @@ func TestFeatureToggleFiles(t *testing.T) {
|
||||||
}
|
}
|
||||||
} else if item.DeletionTimestamp == nil {
|
} else if item.DeletionTimestamp == nil {
|
||||||
item.DeletionTimestamp = &created
|
item.DeletionTimestamp = &created
|
||||||
fmt.Printf("mark feature as deleted")
|
t.Log("mark feature as deleted")
|
||||||
}
|
}
|
||||||
current.Items = append(current.Items, item)
|
current.Items = append(current.Items, item)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
package test
|
package test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
|
@ -56,7 +55,7 @@ func setupTestDB(t *testing.T) *xorm.Engine {
|
||||||
|
|
||||||
t.Cleanup(func() {
|
t.Cleanup(func() {
|
||||||
if err := x.Close(); err != nil {
|
if err := x.Close(); err != nil {
|
||||||
fmt.Printf("failed to close xorm engine: %v", err)
|
t.Logf("failed to close xorm engine: %v", err)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ func TestMigrations(t *testing.T) {
|
||||||
|
|
||||||
t.Cleanup(func() {
|
t.Cleanup(func() {
|
||||||
if err := x.Close(); err != nil {
|
if err := x.Close(); err != nil {
|
||||||
fmt.Printf("failed to close xorm engine: %v", err)
|
t.Logf("failed to close xorm engine: %v", err)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
@ -92,7 +92,7 @@ func TestIntegrationMigrationLock(t *testing.T) {
|
||||||
|
|
||||||
t.Cleanup(func() {
|
t.Cleanup(func() {
|
||||||
if err := x.Close(); err != nil {
|
if err := x.Close(); err != nil {
|
||||||
fmt.Printf("failed to close xorm engine: %v", err)
|
t.Logf("failed to close xorm engine: %v", err)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
@ -203,7 +203,7 @@ func TestMigratorLocking(t *testing.T) {
|
||||||
|
|
||||||
t.Cleanup(func() {
|
t.Cleanup(func() {
|
||||||
if err := x.Close(); err != nil {
|
if err := x.Close(); err != nil {
|
||||||
fmt.Printf("failed to close xorm engine: %v", err)
|
t.Logf("failed to close xorm engine: %v", err)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
@ -250,7 +250,7 @@ func TestDatabaseLocking(t *testing.T) {
|
||||||
|
|
||||||
t.Cleanup(func() {
|
t.Cleanup(func() {
|
||||||
if err := x.Close(); err != nil {
|
if err := x.Close(); err != nil {
|
||||||
fmt.Printf("failed to close xorm engine: %v", err)
|
t.Logf("failed to close xorm engine: %v", err)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
package test
|
package test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
@ -28,7 +27,7 @@ func setupTestDB(t *testing.T) *xorm.Engine {
|
||||||
|
|
||||||
t.Cleanup(func() {
|
t.Cleanup(func() {
|
||||||
if err := x.Close(); err != nil {
|
if err := x.Close(); err != nil {
|
||||||
fmt.Printf("failed to close xorm engine: %v", err)
|
t.Logf("failed to close xorm engine: %v", err)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
package test
|
package test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
|
@ -34,7 +33,7 @@ func setupTestDB(t *testing.T) *xorm.Engine {
|
||||||
|
|
||||||
t.Cleanup(func() {
|
t.Cleanup(func() {
|
||||||
if err := x.Close(); err != nil {
|
if err := x.Close(); err != nil {
|
||||||
fmt.Printf("failed to close xorm engine: %v", err)
|
t.Logf("failed to close xorm engine: %v", err)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -392,7 +392,7 @@ func TestCanSearchByTitle(t *testing.T) {
|
||||||
res, err := index.Search(context.Background(), nil, query, nil)
|
res, err := index.Search(context.Background(), nil, query, nil)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
if res.TotalHits != 1 {
|
if res.TotalHits != 1 {
|
||||||
fmt.Printf("i: %d, v: %s, title: %s", i, v, title)
|
t.Logf("i: %d, v: %s, title: %s", i, v, title)
|
||||||
}
|
}
|
||||||
require.Equal(t, int64(1), res.TotalHits)
|
require.Equal(t, int64(1), res.TotalHits)
|
||||||
|
|
||||||
|
|
@ -402,7 +402,7 @@ func TestCanSearchByTitle(t *testing.T) {
|
||||||
res, err = index.Search(context.Background(), nil, query, nil)
|
res, err = index.Search(context.Background(), nil, query, nil)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
if res.TotalHits != 1 {
|
if res.TotalHits != 1 {
|
||||||
fmt.Printf("i: %d, v: %s, title: %s", i, v, title)
|
t.Logf("i: %d, v: %s, title: %s\n", i, v, title)
|
||||||
}
|
}
|
||||||
|
|
||||||
require.Equal(t, int64(1), res.TotalHits)
|
require.Equal(t, int64(1), res.TotalHits)
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ func TestIntegrationPlaylist(t *testing.T) {
|
||||||
|
|
||||||
// The accepted verbs will change when dual write is enabled
|
// The accepted verbs will change when dual write is enabled
|
||||||
disco := h.GetGroupVersionInfoJSON("playlist.grafana.app")
|
disco := h.GetGroupVersionInfoJSON("playlist.grafana.app")
|
||||||
// fmt.Printf("%s", disco)
|
// t.Logf("%s", disco)
|
||||||
require.JSONEq(t, `[
|
require.JSONEq(t, `[
|
||||||
{
|
{
|
||||||
"version": "v0alpha1",
|
"version": "v0alpha1",
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@ package dashboards
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
|
@ -71,7 +70,7 @@ func TestIntegrationSimpleQuery(t *testing.T) {
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
//fmt.Printf("%s", string(body))
|
//t.Logf("%s", string(body))
|
||||||
|
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
|
@ -90,7 +89,7 @@ func TestIntegrationSimpleQuery(t *testing.T) {
|
||||||
|
|
||||||
body, err = result.Raw()
|
body, err = result.Raw()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
fmt.Printf("OUT: %s", string(body))
|
t.Logf("OUT: %s", string(body))
|
||||||
|
|
||||||
rsp := &backend.QueryDataResponse{}
|
rsp := &backend.QueryDataResponse{}
|
||||||
err = json.Unmarshal(body, rsp)
|
err = json.Unmarshal(body, rsp)
|
||||||
|
|
@ -135,7 +134,7 @@ func TestIntegrationSimpleQuery(t *testing.T) {
|
||||||
Do(context.Background())
|
Do(context.Background())
|
||||||
|
|
||||||
body, err = result.Raw()
|
body, err = result.Raw()
|
||||||
//fmt.Printf("OUT: %s", string(body))
|
//t.Logf("OUT: %s", string(body))
|
||||||
|
|
||||||
require.Error(t, err, "expecting a 400")
|
require.Error(t, err, "expecting a 400")
|
||||||
require.JSONEq(t, `{
|
require.JSONEq(t, `{
|
||||||
|
|
|
||||||
|
|
@ -210,7 +210,7 @@ var objectToStringConverter = data.FieldConverter{
|
||||||
|
|
||||||
data, err := json.Marshal(kustoValue)
|
data, err := json.Marshal(kustoValue)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("failed to marshal column value: %s", err)
|
return nil, fmt.Errorf("failed to marshal column value: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
asString := string(data)
|
asString := string(data)
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
"log/slog"
|
||||||
"runtime/debug"
|
"runtime/debug"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
|
@ -265,7 +266,8 @@ func copyData(field *data.Field, col arrow.Array) error {
|
||||||
case arrow.DURATION:
|
case arrow.DURATION:
|
||||||
copyBasic[int64](field, array.NewInt64Data(colData))
|
copyBasic[int64](field, array.NewInt64Data(colData))
|
||||||
default:
|
default:
|
||||||
fmt.Printf("datatype %s is unhandled", col.DataType().ID())
|
// FIXME: Should this return an error instead?
|
||||||
|
slog.Error("datatype is unhandled", "type", col.DataType().ID())
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ package converter
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"log/slog"
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
|
@ -362,7 +363,7 @@ func typeOf(value interface{}) data.FieldType {
|
||||||
case *bool:
|
case *bool:
|
||||||
return data.FieldTypeNullableBool
|
return data.FieldTypeNullableBool
|
||||||
default:
|
default:
|
||||||
fmt.Printf("unknown value type: %v", v)
|
slog.Error("unknown influx value type", "value", v)
|
||||||
return data.FieldTypeNullableJSON
|
return data.FieldTypeNullableJSON
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue