콘텐츠로 이동

logc

type (
LogConf = logx.LogConf
LogField = logx.LogField
)

모든 로그에 표시될 전역 필드를 추가합니다.

func AddGlobalFields(fields ...LogField)

예제:

logc.AddGlobalFields(logc.Field("app", "exampleApp"))

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 레벨로 로그 메시지를 남깁니다.

func Debug(ctx context.Context, v ...interface{})

예제:

logc.Debug(context.Background(), "This is a debug message")

debug 레벨로 포맷된 로그 메시지를 남깁니다.

func Debugf(ctx context.Context, format string, v ...interface{})

예제:

logc.Debugf(context.Background(), "This is a %s message", "formatted debug")

debug 레벨로 JSON 내용을 로그에 남깁니다.

func Debugv(ctx context.Context, v interface{})

예제:

logc.Debugv(context.Background(), map[string]interface{}{"key": "value"})

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")

error 레벨로 포맷된 로그 메시지를 남깁니다.

func Errorf(ctx context.Context, format string, v ...any)

예제:

logc.Errorf(context.Background(), "This is a %s message", "formatted error")

error 레벨로 JSON 내용을 로그에 남깁니다.

func Errorv(ctx context.Context, v any)

예제:

logc.Errorv(context.Background(), map[string]interface{}{"error": "something went wrong"})

로그 메시지 사용하여 필드 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 레벨로 로그 메시지를 남깁니다.

func Info(ctx context.Context, v ...any)

예제:

logc.Info(context.Background(), "This is an info message")

info 레벨로 포맷된 로그 메시지를 남깁니다.

func Infof(ctx context.Context, format string, v ...any)

예제:

logc.Infof(context.Background(), "This is a %s message", "formatted info")

info 레벨로 JSON 내용을 로그에 남깁니다.

func Infov(ctx context.Context, v any)

예제:

logc.Infov(context.Background(), map[string]interface{}{"info": "some information"})

info 레벨로 필드가 포함된 로그 메시지를 남깁니다.

func Infow(ctx context.Context, msg string, fields ...LogField)

예제:

logc.Infow(context.Background(), "Info message with fields", logc.Field("key", "value"))

error가 nil인지 확인하고, nil이 아니면 오류를 기록한 뒤 프로그램을 종료합니다.

func Must(err error)

예제:

logc.Must(errors.New("fatal error"))

주어진 설정으로 로깅을 초기화합니다. 오류가 있으면 종료합니다.

func Must설정(c logx.LogConf)

예제:

config := logx.LogConf{
ServiceName: "exampleService",
Mode: "console",
}
logc.Must설정(config)

일부 로그를 숨기도록 로그 레벨을 설정합니다.

func SetLevel(level uint32)

예제:

logc.SetLevel(logx.LevelInfo)
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")

slow 로그 레벨로 포맷된 로그 메시지를 남깁니다.

func Slowf(ctx context.Context, format string, v ...any)

예제:

logc.Slowf(context.Background(), "This is a %s message", "formatted slow log")

slow 로그 레벨로 JSON 내용을 로그에 남깁니다.

func Slowv(ctx context.Context, v any)

예제:

logc.Slowv(context.Background(), map[string]interface{}{"slow": "operation details"})

로그 메시지 사용하여 필드 at 느린 로그 level.

func Sloww(ctx context.Context, msg string, fields ...LogField)

예제:

logc.Sloww(context.Background(), "Slow log message with fields", logc.Field("key", "value"))