메인 콘텐츠로 건너뛰기
버전: v2.4.0

Log

The Wails runtime provides a logging mechanism that may be called from Go or JavaScript. 대부분처럼 loggers 에는 다양한 로그 수준이 있습니다:

  • Trace
  • Debug
  • Info
  • Warning
  • Error
  • Fatal

Logger는 현재 이상의 로그 수준에서 모든 로그 메시지를 출력합니다. Example: Debug 로그 level은 Trace 메시지를 제외한 모든 메시지를 출력합니다.

LogPrint​

주어진 메시지를 원본 메시지로 기록합니다.

Go: LogPrint(ctx context.Context, message string)
JS: LogPrint(message: string)

LogPrintf​

주어진 메시지를 원본 메시지로 기록합니다.

Go: LogPrintf(ctx context.Context, format string, args ...interface{})

LogTrace​

Trace 로그 수준에서 지정된 메시지를 기록합니다.

Go: LogTrace(ctx context.Context, message string)
JS: LogTrace(message: string)

LogTracef​

Trace 로그 수준에서 지정된 메시지를 기록합니다.

Go: LogTracef(ctx context.Context, format string, args ...interface{})

LogDebug​

Debug 로그 수준에서 지정된 메시지를 기록합니다.

Go: LogDebug(ctx context.Context, message string)
JS: LogDebug(message: string)

LogDebugf​

Debug 로그 수준에서 지정된 메시지를 기록합니다.

Go: LogDebugf(ctx context.Context, format string, args ...interface{})

LogInfo​

Info 로그 수준에서 지정된 메시지를 기록합니다.

Go: LogInfo(ctx context.Context, message string)
JS: LogInfo(message: string)

LogInfof​

Info 로그 수준에서 지정된 메시지를 기록합니다.

Go: LogInfof(ctx context.Context, format string, args ...interface{})

LogWarning​

Warning 로그 수준에서 지정된 메시지를 기록합니다.

Go: LogWarning(ctx context.Context, message string)
JS: LogWarning(message: string)

LogWarningf​

Warning 로그 수준에서 지정된 메시지를 기록합니다.

Go: LogWarningf(ctx context.Context, format string, args ...interface{})

LogError​

Error 로그 수준에서 지정된 메시지를 기록합니다.

Go: LogError(ctx context.Context, message string)
JS: LogError(message: string)

LogErrorf​

Error 로그 수준에서 지정된 메시지를 기록합니다.

Go: LogErrorf(ctx context.Context, format string, args ...interface{})

LogFatal​

Fatal 로그 수준에서 지정된 메시지를 기록합니다.

Go: LogFatal(ctx context.Context, message string)
JS: LogFatal(message: string)

LogFatalf​

Fatal 로그 수준에서 지정된 메시지를 기록합니다.

Go: LogFatalf(ctx context.Context, format string, args ...interface{})

LogSetLogLevel​

로그 레벨을 설정합니다. In JavaScript, the number relates to the following log levels:

값로그 레벨
1Trace
2Debug
3Info
4Warning
5Error

Go: LogSetLogLevel(ctx context.Context, level logger.LogLevel)
JS: LogSetLogLevel(level: number)

커스텀 Logger 사용하기​

사용자 커스텀 logger는 Logger를 사용하여 제공하여 사용할 수 있습니다. 응용 프로그램 옵션. 유일한 요구 사항은 logger가 logger.Logger 인터페이스를 구현한다는 것입니다. 이는 github.com/wailsapp/wails/v2/pkg/logger에 정의되어 있습니다:

logger.go
type Logger interface {
Print(message string)
Trace(message string)
Debug(message string)
Info(message string)
Warning(message string)
Error(message string)
Fatal(message string)
}