Skip to content

Commit

Permalink
feat: print log error (#43)
Browse files Browse the repository at this point in the history
* feat: print log error

* chore: bump ali version
  • Loading branch information
deryrahman authored Nov 20, 2024
1 parent ef5d5ea commit 784ad27
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion mc2mc/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/goto/transformers/mc2mc
go 1.22.3

require (
github.com/aliyun/aliyun-odps-go-sdk v0.3.8
github.com/aliyun/aliyun-odps-go-sdk v0.3.15
github.com/pkg/errors v0.9.1
github.com/stretchr/testify v1.9.0
go.opentelemetry.io/otel v1.30.0
Expand Down
4 changes: 2 additions & 2 deletions mc2mc/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ github.com/alibabacloud-go/debug v1.0.1 h1:MsW9SmUtbb1Fnt3ieC6NNZi6aEwrXfDksD4QA
github.com/alibabacloud-go/debug v1.0.1/go.mod h1:8gfgZCCAC3+SCzjWtY053FrOcd4/qlH6IHTI4QyICOc=
github.com/alibabacloud-go/tea v1.2.2 h1:aTsR6Rl3ANWPfqeQugPglfurloyBJY85eFy7Gc1+8oU=
github.com/alibabacloud-go/tea v1.2.2/go.mod h1:CF3vOzEMAG+bR4WOql8gc2G9H3EkH3ZLAQdpmpXMgwk=
github.com/aliyun/aliyun-odps-go-sdk v0.3.8 h1:IUMwvosuHiY02/xEAGw6zFOKv1HR84B3HmDGmMrbo/U=
github.com/aliyun/aliyun-odps-go-sdk v0.3.8/go.mod h1:t/tgF/iN5aAs/gLL7sEI8/qdax4NuFCKEjO3OJbHZqI=
github.com/aliyun/aliyun-odps-go-sdk v0.3.15 h1:HkWki3g7G0xEAyxSAChqSDxLw8NCl7PFc8KxcECXReQ=
github.com/aliyun/aliyun-odps-go-sdk v0.3.15/go.mod h1:t/tgF/iN5aAs/gLL7sEI8/qdax4NuFCKEjO3OJbHZqI=
github.com/aliyun/credentials-go v1.3.10 h1:45Xxrae/evfzQL9V10zL3xX31eqgLWEaIdCoPipOEQA=
github.com/aliyun/credentials-go v1.3.10/go.mod h1:Jm6d+xIgwJVLVWT561vy67ZRP4lPTQxMbEYRuT2Ti1U=
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
Expand Down
5 changes: 5 additions & 0 deletions mc2mc/internal/logger/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,8 @@ func NewLogger(logLevel string) (*slog.Logger, error) {
writter := slog.NewTextHandler(os.Stdout, &slog.HandlerOptions{Level: level})
return slog.New(writter), nil
}

func NewDefaultLogger() *slog.Logger {
l, _ := NewLogger("INFO")
return l
}
5 changes: 5 additions & 0 deletions mc2mc/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,19 @@ import (
"os"

_ "github.com/aliyun/aliyun-odps-go-sdk/sqldriver"
"github.com/goto/transformers/mc2mc/internal/logger"
)

func main() {
// initiate default logger
l := logger.NewDefaultLogger()

// mc2mc is the main function to execute the mc2mc transformation
// which reads the configuration, sets up the client and executes the query.
// It also handles graceful shutdown by listening to os signals.
// It returns error if any.
if err := mc2mc(); err != nil {
l.Error(fmt.Sprintf("error: %s", err.Error()))
fmt.Printf("error: %+v\n", err)
os.Exit(1)
}
Expand Down

0 comments on commit 784ad27

Please sign in to comment.