Skip to content

Commit

Permalink
fix(mc2mc): print log with new line + execution project (#62)
Browse files Browse the repository at this point in the history
fix: print log with new line + execution project
  • Loading branch information
deryrahman authored Jan 7, 2025
1 parent 107c2df commit b6fd13a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion mc2mc/internal/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func (c *Client) Close() error {

func (c *Client) Execute(ctx context.Context, query string) error {
// execute query with odps client
c.logger.Info(fmt.Sprintf("execute: %s", query))
c.logger.Info(fmt.Sprintf("query to execute:\n%s", query))
if err := c.OdpsClient.ExecSQL(ctx, query); err != nil {
return errors.WithStack(err)
}
Expand Down
3 changes: 3 additions & 0 deletions mc2mc/internal/client/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ func SetupDefaultProject(project string) SetupFn {
if c.OdpsClient == nil {
return errors.New("odps client is required")
}
if project == "" {
return nil
}
c.OdpsClient.SetDefaultProject(project)
return nil
}
Expand Down
5 changes: 2 additions & 3 deletions mc2mc/internal/logger/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package logger

import (
"log/slog"
"os"

"github.com/pkg/errors"
)
Expand All @@ -13,8 +12,8 @@ func NewLogger(logLevel string) (*slog.Logger, error) {
return nil, errors.WithStack(err)
}

writter := slog.NewTextHandler(os.Stdout, &slog.HandlerOptions{Level: level})
return slog.New(writter), nil
slog.SetLogLoggerLevel(level)
return slog.Default(), nil
}

func NewDefaultLogger() *slog.Logger {
Expand Down

0 comments on commit b6fd13a

Please sign in to comment.