fix: modify module name
The go-dyclog SDK provides simple log APIs for douyincloud developer
// main.go package main import ( "context" "github.com/bytedance/go-dyclog" ) func main() { // Start your vefaas function =D. vefaas.Start(handler) } // Define your handler function. func handler(ctx context.Context, r *events.HTTPRequest) (*events.EventResponse, error) { // inject logid into context dyclog.InjectLogIDToCtx(ctx, r.Headers["x-tt-logid"]) // close logger defer func() { _ = dyclog.Close() }() // Support Debug, Info, Warn, Error, Fatal dyclog.Debug("received new request: %s %s, request id: %s\n", r.HTTPMethod, r.Path, vefaascontext.RequestIdFrom) dyclog.CtxDebug(ctx, "received new request: %s %s, request id: %s\n", r.HTTPMethod, r.Path, vefaascontext.RequestIdFrom) return &events.EventResponse{ Headers: map[string]string{ "Content-Type": "application/json", }, Body: []byte("Hello veFaaS!"), }, nil }
basis log methods
with context basis log methods
setting methods
The following two methods use ConsoleWriter by default to output logs through stdout
// the first method import "github.com/bytedance/go-dyclog" func func main() { dyclog.Debug("test go-dyclog!") dyclog.CtxDebug(context.Background(), "test go-dyclog!") _ = dyclog.Close() }
// the second method import "github.com/bytedance/go-dyclog" var Logger *dyclog.Logger func init() { Logger = NewDefaultLogger() } func func main() { Logger.Debug("test go-dyclog!") Logger.CtxDebug(context.Background(), "test go-dyclog!") _ = Logger.Close() }
The following cases use FileWriter to write log files. Douyin Cloud does not support file log collection for the time being, so stay tuned
import "github.com/bytedance/go-dyclog" var Logger *dyclog.Logger func init() { // the second args, RotationWindow, enum 0 Daily 1 Hourly Logger = dyclog.NewLogger(dyclog.NewFileWriter("./logs/dyc.log", 0)) } func func main() { Logger.Debug("test go-dyclog!") Logger.CtxDebug(context.Background(), "test go-dyclog!") _ = Logger.Close() }
If you discover a potential security issue in this project, or think you may have discovered a security issue, we ask that you notify Bytedance Security via our security center or vulnerability reporting email.
Please do not create a public GitHub issue.
This project is licensed under the Apache-2.0 License.
版权所有:中国计算机学会技术支持:开源发展技术委员会 京ICP备13000930号-9 京公网安备 11010802032778号
Overview
The go-dyclog SDK provides simple log APIs for douyincloud developer
How It Works
Features
Interfaces
basis log methodswith context basis log methodssetting methodsExamples
The following two methods use ConsoleWriter by default to output logs through stdout
The following cases use FileWriter to write log files. Douyin Cloud does not support file log collection for the time being, so stay tuned
Security
If you discover a potential security issue in this project, or think you may have discovered a security issue, we ask that you notify Bytedance Security via our security center or vulnerability reporting email.
Please do not create a public GitHub issue.
License
This project is licensed under the Apache-2.0 License.