log

package
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 1, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AllLevels = logrus.AllLevels

AllLevels logrus.AllLevels의 별칭입니다.

View Source
var Debug = logrus.Debug

Debug 레벨 로그를 기록합니다.

View Source
var Debugf = logrus.Debugf

포맷팅된 Debug 레벨 로그를 기록합니다.

View Source
var Error = logrus.Error

Error 레벨 로그를 기록합니다.

View Source
var Errorf = logrus.Errorf

포맷팅된 Error 레벨 로그를 기록합니다.

View Source
var Fatal = logrus.Fatal

Fatal 레벨 로그를 기록합니다. (이후 os.Exit(1) 호출)

View Source
var Fatalf = logrus.Fatalf

포맷팅된 Fatal 레벨 로그를 기록합니다. (이후 os.Exit(1) 호출)

View Source
var Info = logrus.Info

Info 레벨 로그를 기록합니다.

View Source
var Infof = logrus.Infof

포맷팅된 Info 레벨 로그를 기록합니다.

View Source
var Panic = logrus.Panic

Panic 레벨 로그를 기록합니다. (이후 panic() 발생)

View Source
var Panicf = logrus.Panicf

포맷팅된 Panic 레벨 로그를 기록합니다. (이후 panic() 발생)

View Source
var Trace = logrus.Trace

Trace 레벨 로그를 기록합니다.

View Source
var Tracef = logrus.Tracef

포맷팅된 Trace 레벨 로그를 기록합니다.

View Source
var Warn = logrus.Warn

Warn 레벨 로그를 기록합니다.

View Source
var Warnf = logrus.Warnf

포맷팅된 Warn 레벨 로그를 기록합니다.

Functions

func SetFormatter added in v1.1.0

func SetFormatter(formatter Formatter)

SetFormatter 전역 로거의 포맷터를 설정합니다.

func SetLevel added in v1.1.0

func SetLevel(level Level)

SetLevel 전역 로거의 레벨을 설정합니다.

func SetOutput added in v1.1.0

func SetOutput(out io.Writer)

SetOutput 전역 로거의 출력을 설정합니다.

func Setup added in v1.1.0

func Setup(opts Options) (io.Closer, error)

Setup 전역 로깅 시스템을 초기화하고 설정된 옵션에 따라 파일 출력을 구성합니다.

주의:

  • 애플리케이션 시작 시점(main 함수 도입부)에 호출하는 것을 권장합니다.
  • 반환된 Closer는 반드시 defer를 통해 리소스가 해제되도록 보장해야 합니다.

Types

type Entry added in v1.1.0

type Entry = logrus.Entry

Entry logrus.Entry의 별칭입니다.

func WithComponent

func WithComponent(component string) *Entry

WithComponent 로그의 출처(Component)를 명시하는 'component' 필드를 컨텍스트에 추가합니다.

func WithComponentAndFields

func WithComponentAndFields(component string, fields Fields) *Entry

WithComponentAndFields 'component' 필드와 추가적인 구조화된 필드들을 동시에 컨텍스트에 추가합니다.

func WithContext added in v1.1.0

func WithContext(ctx context.Context) *Entry

WithContext 컨텍스트를 로그에 연동합니다. (Trace ID 추적 등에 활용)

func WithError added in v1.1.0

func WithError(err error) *Entry

WithError 에러를 로그 컨텍스트에 추가합니다. ("error" 필드)

func WithField added in v1.1.0

func WithField(key string, value interface{}) *Entry

WithField 단일 키-값 쌍을 로그 컨텍스트에 추가합니다.

func WithFields added in v1.1.0

func WithFields(fields Fields) *Entry

WithFields 구조화된 필드(Key-Value)를 로그 컨텍스트에 추가합니다.

func WithTime added in v1.1.0

func WithTime(t time.Time) *Entry

WithTime 커스텀 타임스탬프를 로그 컨텍스트에 설정합니다.

type Fields added in v1.1.0

type Fields = logrus.Fields

Fields logrus.Fields의 별칭입니다.

type Formatter added in v1.1.0

type Formatter = logrus.Formatter

Formatter logrus.Formatter의 별칭입니다.

type Hook added in v1.1.0

type Hook = logrus.Hook

Hook logrus.Hook의 별칭입니다.

type JSONFormatter added in v1.1.0

type JSONFormatter = logrus.JSONFormatter

JSONFormatter logrus.JSONFormatter의 별칭입니다.

type Level added in v1.1.0

type Level = logrus.Level

Level logrus.Level의 별칭입니다.

const (
	// PanicLevel 가장 높은 심각도입니다. 로그를 기록한 후 panic()을 호출하여 현재 고루틴을 중단합니다.
	// 복구 불가능한 치명적인 내부 오류 발생 시 사용합니다.
	PanicLevel Level = logrus.PanicLevel

	// FatalLevel 치명적인 오류입니다. 로그를 기록한 후 os.Exit(1)을 호출하여 프로세스를 즉시 종료합니다.
	// 애플리케이션 시작 실패, 필수 리소스 로드 실패 등 프로세스가 더 이상 진행할 수 없을 때 사용합니다.
	FatalLevel Level = logrus.FatalLevel

	// ErrorLevel 에러 상황입니다. 프로세스를 종료하지는 않지만, 관리자의 개입이나 버그 수정이 필요한 상태를 나타냅니다.
	ErrorLevel Level = logrus.ErrorLevel

	// WarnLevel 경고 상황입니다. 당장 에러는 아니지만 잠재적인 문제가 있거나 주의가 필요한 상태를 나타냅니다.
	WarnLevel Level = logrus.WarnLevel

	// InfoLevel 일반적인 정보입니다. 시스템의 정상적인 작동 흐름이나 상태 변화를 기록합니다.
	InfoLevel Level = logrus.InfoLevel

	// DebugLevel 디버깅 정보입니다. 개발 및 테스트 단계에서 문제 해결을 위해 상세한 정보를 기록합니다.
	DebugLevel Level = logrus.DebugLevel

	// TraceLevel 가장 세밀한 정보입니다. Debug 레벨보다 더 상세한 데이터 흐름, 내부 변수 상태 등을 추적합니다.
	TraceLevel Level = logrus.TraceLevel
)

type Logger added in v1.1.0

type Logger = logrus.Logger

Logger logrus.Logger의 별칭입니다.

func StandardLogger added in v1.1.0

func StandardLogger() *Logger

StandardLogger logrus 라이브러리의 전역 표준 로거(Standard Logger) 인스턴스를 반환합니다. (참고: 이 인스턴스는 pkg/log.Setup()을 통해 모든 설정이 완료된 상태입니다.)

type Options added in v1.1.0

type Options struct {
	Name  string // 로그 파일명 생성에 사용될 애플리케이션 식별자
	Dir   string // 로그 파일이 저장될 디렉토리 경로
	Level Level  // 로그 레벨

	MaxAge     int // 오래된 로그 삭제 기준일 (일 단위, 0: 삭제 안 함)
	MaxSizeMB  int // 로그 파일 최대 크기 (MB, 0: 기본값 10MB 사용)
	MaxBackups int // 최대 백업 파일 수 (0: 기본값 20개 사용)

	EnableCriticalLog bool // ERROR 이상(ERROR, FATAL, PANIC)의 치명적 로그를 별도 파일로 분리 저장할지 여부
	EnableVerboseLog  bool // DEBUG 이하(DEBUG, TRACE)의 상세 로그를 별도 파일로 분리 저장할지 여부
	EnableConsoleLog  bool // 표준 출력(Stdout)에도 로그를 출력할지 여부 (개발 환경 권장)

	// 로그를 호출한 소스 코드의 위치(파일명:라인번호)를 함께 기록할지 여부
	// 예: true로 설정 시 "main.go:55" 처럼 로그가 발생한 위치를 알 수 있어 디버깅에 유용합니다.
	ReportCaller bool

	// 로그에 출력되는 파일 경로가 너무 길 때, 앞부분을 잘라내어 보기 좋게 만듭니다.
	// 예: "github.com/my/project/pkg/server.go" -> prefix가 "github.com/my/project"라면 "pkg/server.go"만 출력됨
	CallerPathPrefix string
}

Options 로거 설정을 위한 구조체입니다.

func NewDevelopmentOptions added in v1.1.0

func NewDevelopmentOptions(appName string) Options

NewDevelopmentOptions 개발(Development) 환경에 최적화된 로그 설정을 반환합니다.

func NewProductionOptions added in v1.1.0

func NewProductionOptions(appName string) Options

NewProductionOptions 운영(Production) 환경에 최적화된 로그 설정을 반환합니다.

func (*Options) Validate added in v1.1.0

func (opts *Options) Validate() error

Validate는 Options 구조체의 필드 값이 유효한지 검증합니다.

type TextFormatter added in v1.1.0

type TextFormatter = logrus.TextFormatter

TextFormatter logrus.TextFormatter의 별칭입니다.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL