logc
타입 Definitions
섹션 제목: “타입 Definitions”type ( LogConf = logx.LogConf LogField = logx.LogField)AddGlobalFields
섹션 제목: “AddGlobalFields”모든 로그에 표시될 전역 필드를 추가합니다.
func AddGlobalFields(fields ...LogField)예제:
logc.AddGlobalFields(logc.Field("app", "exampleApp"))Alert
섹션 제목: “Alert”alert 레벨로 로그 메시지를 남기며, 메시지는 오류 로그에 기록됩니다.
func Alert(_ context.Context, v string)예제:
logc.Alert(context.Background(), "This is an alert message")Closes 로깅 시스템.
func Close() error예제:
if err := logc.Close(); err != nil { fmt.Println("Error closing log system:", err)}Debug
섹션 제목: “Debug”debug 레벨로 로그 메시지를 남깁니다.
func Debug(ctx context.Context, v ...interface{})예제:
logc.Debug(context.Background(), "This is a debug message")Debugf
섹션 제목: “Debugf”debug 레벨로 포맷된 로그 메시지를 남깁니다.
func Debugf(ctx context.Context, format string, v ...interface{})예제:
logc.Debugf(context.Background(), "This is a %s message", "formatted debug")Debugv
섹션 제목: “Debugv”debug 레벨로 JSON 내용을 로그에 남깁니다.
func Debugv(ctx context.Context, v interface{})예제:
logc.Debugv(context.Background(), map[string]interface{}{"key": "value"})Debugw
섹션 제목: “Debugw”debug 레벨로 필드가 포함된 로그 메시지를 남깁니다.
func Debugw(ctx context.Context, msg string, fields ...LogField)예제:
logc.Debugw(context.Background(), "Debug message with fields", logc.Field("key", "value"))로그 메시지 at 오류 level.
func Error(ctx context.Context, v ...any)예제:
logc.Error(context.Background(), "This is an error message")Errorf
섹션 제목: “Errorf”error 레벨로 포맷된 로그 메시지를 남깁니다.
func Errorf(ctx context.Context, format string, v ...any)예제:
logc.Errorf(context.Background(), "This is a %s message", "formatted error")Errorv
섹션 제목: “Errorv”error 레벨로 JSON 내용을 로그에 남깁니다.
func Errorv(ctx context.Context, v any)예제:
logc.Errorv(context.Background(), map[string]interface{}{"error": "something went wrong"})Errorw
섹션 제목: “Errorw”로그 메시지 사용하여 필드 at 오류 level.
func Errorw(ctx context.Context, msg string, fields ...LogField)예제:
logc.Errorw(context.Background(), "Error message with fields", logc.Field("key", "value"))반환 로그 필드 위한 given key과 value.
func Field(key string, value any) LogField예제:
field := logc.Field("key", "value")Info
섹션 제목: “Info”info 레벨로 로그 메시지를 남깁니다.
func Info(ctx context.Context, v ...any)예제:
logc.Info(context.Background(), "This is an info message")Infof
섹션 제목: “Infof”info 레벨로 포맷된 로그 메시지를 남깁니다.
func Infof(ctx context.Context, format string, v ...any)예제:
logc.Infof(context.Background(), "This is a %s message", "formatted info")Infov
섹션 제목: “Infov”info 레벨로 JSON 내용을 로그에 남깁니다.
func Infov(ctx context.Context, v any)예제:
logc.Infov(context.Background(), map[string]interface{}{"info": "some information"})Infow
섹션 제목: “Infow”info 레벨로 필드가 포함된 로그 메시지를 남깁니다.
func Infow(ctx context.Context, msg string, fields ...LogField)예제:
logc.Infow(context.Background(), "Info message with fields", logc.Field("key", "value"))Must
섹션 제목: “Must”error가 nil인지 확인하고, nil이 아니면 오류를 기록한 뒤 프로그램을 종료합니다.
func Must(err error)예제:
logc.Must(errors.New("fatal error"))Must설정
섹션 제목: “Must설정”주어진 설정으로 로깅을 초기화합니다. 오류가 있으면 종료합니다.
func Must설정(c logx.LogConf)예제:
config := logx.LogConf{ ServiceName: "exampleService", Mode: "console",}logc.Must설정(config)SetLevel
섹션 제목: “SetLevel”일부 로그를 숨기도록 로그 레벨을 설정합니다.
func SetLevel(level uint32)예제:
logc.SetLevel(logx.LevelInfo)SetUp
섹션 제목: “SetUp”func SetUp(c LogConf) error예제:
config := logc.LogConf{ ServiceName: "exampleService", Mode: "console",}if err := logc.SetUp(config); err != nil { fmt.Println("Error setting up log system:", err)}로그 메시지 at 느린 로그 level.
func Slow(ctx context.Context, v ...any)예제:
logc.Slow(context.Background(), "This is a slow log message")Slowf
섹션 제목: “Slowf”slow 로그 레벨로 포맷된 로그 메시지를 남깁니다.
func Slowf(ctx context.Context, format string, v ...any)예제:
logc.Slowf(context.Background(), "This is a %s message", "formatted slow log")Slowv
섹션 제목: “Slowv”slow 로그 레벨로 JSON 내용을 로그에 남깁니다.
func Slowv(ctx context.Context, v any)예제:
logc.Slowv(context.Background(), map[string]interface{}{"slow": "operation details"})Sloww
섹션 제목: “Sloww”로그 메시지 사용하여 필드 at 느린 로그 level.
func Sloww(ctx context.Context, msg string, fields ...LogField)예제:
logc.Sloww(context.Background(), "Slow log message with fields", logc.Field("key", "value"))