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
pull/102979/head
Mariell Hoversholm 2 months ago committed by GitHub
parent 9094c73e33
commit e1e1d3fd9f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 2
      pkg/build/config/version.go
  2. 25
      pkg/cmd/grafana-cli/logger/logger.go
  3. 2
      pkg/registry/apps/playlist/conversions_test.go
  4. 2
      pkg/services/annotations/annotationsimpl/xorm_store.go
  5. 2
      pkg/services/featuremgmt/toggles_gen_test.go
  6. 3
      pkg/services/sqlstore/migrations/accesscontrol/test/ac_test.go
  7. 8
      pkg/services/sqlstore/migrations/migrations_test.go
  8. 3
      pkg/services/sqlstore/migrations/ualert/test/testing.go
  9. 3
      pkg/services/sqlstore/migrations/usermig/test/user_test.go
  10. 4
      pkg/storage/unified/search/bleve_search_test.go
  11. 2
      pkg/tests/apis/playlist/playlist_test.go
  12. 7
      pkg/tests/apis/query/query_test.go
  13. 2
      pkg/tsdb/azuremonitor/loganalytics/azure-response-table-frame.go
  14. 4
      pkg/tsdb/influxdb/fsql/arrow.go
  15. 3
      pkg/tsdb/influxdb/influxql/converter/converter.go

@ -121,7 +121,7 @@ func CheckDroneTargetBranch() (VersionMode, error) {
if rePRCheckBranch.MatchString(target) {
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
}

@ -2,6 +2,7 @@ package logger
import (
"fmt"
"strings"
)
var (
@ -10,40 +11,48 @@ var (
func Debug(args ...any) {
if debugmode {
fmt.Print(args...)
fmt.Println(args...)
}
}
func Debugf(fmtString string, args ...any) {
if debugmode {
fmt.Printf(fmtString, args...)
fmt.Printf(addMissingNewline(fmtString), args...)
}
}
func Error(args ...any) {
fmt.Print(args...)
fmt.Println(args...)
}
func Errorf(fmtString string, args ...any) {
fmt.Printf(fmtString, args...)
fmt.Printf(addMissingNewline(fmtString), args...)
}
func Info(args ...any) {
fmt.Print(args...)
fmt.Println(args...)
}
func Infof(fmtString string, args ...any) {
fmt.Printf(fmtString, args...)
fmt.Printf(addMissingNewline(fmtString), args...)
}
func Warn(args ...any) {
fmt.Print(args...)
fmt.Println(args...)
}
func Warnf(fmtString string, args ...any) {
fmt.Printf(fmtString, args...)
fmt.Printf(addMissingNewline(fmtString), args...)
}
func SetDebug(value bool) {
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, "", " ")
require.NoError(t, err)
// fmt.Printf("%s", string(out))
// t.Logf("%s", string(out))
require.JSONEq(t, `{
"metadata": {
"name": "abc",

@ -279,7 +279,7 @@ func (r *xormRepositoryImpl) Get(ctx context.Context, query annotations.ItemQuer
params = append(params, query.OrgID)
if query.AnnotationID != 0 {
// fmt.Print("annotation query")
// fmt.Println("annotation query")
sql.WriteString(` AND a.id = ?`)
params = append(params, query.AnnotationID)
}

@ -92,7 +92,7 @@ func TestFeatureToggleFiles(t *testing.T) {
}
} else if item.DeletionTimestamp == nil {
item.DeletionTimestamp = &created
fmt.Printf("mark feature as deleted")
t.Log("mark feature as deleted")
}
current.Items = append(current.Items, item)
}

@ -1,7 +1,6 @@
package test
import (
"fmt"
"testing"
"time"
@ -56,7 +55,7 @@ func setupTestDB(t *testing.T) *xorm.Engine {
t.Cleanup(func() {
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() {
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() {
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() {
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() {
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
import (
"fmt"
"testing"
"github.com/stretchr/testify/require"
@ -28,7 +27,7 @@ func setupTestDB(t *testing.T) *xorm.Engine {
t.Cleanup(func() {
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
import (
"fmt"
"testing"
"time"
@ -34,7 +33,7 @@ func setupTestDB(t *testing.T) *xorm.Engine {
t.Cleanup(func() {
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)
require.NoError(t, err)
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)
@ -402,7 +402,7 @@ func TestCanSearchByTitle(t *testing.T) {
res, err = index.Search(context.Background(), nil, query, nil)
require.NoError(t, err)
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)

@ -53,7 +53,7 @@ func TestIntegrationPlaylist(t *testing.T) {
// The accepted verbs will change when dual write is enabled
disco := h.GetGroupVersionInfoJSON("playlist.grafana.app")
// fmt.Printf("%s", disco)
// t.Logf("%s", disco)
require.JSONEq(t, `[
{
"version": "v0alpha1",

@ -3,7 +3,6 @@ package dashboards
import (
"context"
"encoding/json"
"fmt"
"net/http"
"testing"
@ -71,7 +70,7 @@ func TestIntegrationSimpleQuery(t *testing.T) {
},
})
//fmt.Printf("%s", string(body))
//t.Logf("%s", string(body))
require.NoError(t, err)
@ -90,7 +89,7 @@ func TestIntegrationSimpleQuery(t *testing.T) {
body, err = result.Raw()
require.NoError(t, err)
fmt.Printf("OUT: %s", string(body))
t.Logf("OUT: %s", string(body))
rsp := &backend.QueryDataResponse{}
err = json.Unmarshal(body, rsp)
@ -135,7 +134,7 @@ func TestIntegrationSimpleQuery(t *testing.T) {
Do(context.Background())
body, err = result.Raw()
//fmt.Printf("OUT: %s", string(body))
//t.Logf("OUT: %s", string(body))
require.Error(t, err, "expecting a 400")
require.JSONEq(t, `{

@ -210,7 +210,7 @@ var objectToStringConverter = data.FieldConverter{
data, err := json.Marshal(kustoValue)
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)

@ -5,6 +5,7 @@ import (
"errors"
"fmt"
"io"
"log/slog"
"runtime/debug"
"time"
@ -265,7 +266,8 @@ func copyData(field *data.Field, col arrow.Array) error {
case arrow.DURATION:
copyBasic[int64](field, array.NewInt64Data(colData))
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

@ -3,6 +3,7 @@ package converter
import (
"errors"
"fmt"
"log/slog"
"strconv"
"time"
@ -362,7 +363,7 @@ func typeOf(value interface{}) data.FieldType {
case *bool:
return data.FieldTypeNullableBool
default:
fmt.Printf("unknown value type: %v", v)
slog.Error("unknown influx value type", "value", v)
return data.FieldTypeNullableJSON
}
}

Loading…
Cancel
Save