mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-03 06:01:52 +08:00
Feature: Go logger "f" equivalents
This commit is contained in:
parent
073f8202e5
commit
7af39e4819
@ -2,6 +2,7 @@ package runtime
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"fmt"
|
||||||
"github.com/wailsapp/wails/v2/pkg/logger"
|
"github.com/wailsapp/wails/v2/pkg/logger"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -47,6 +48,55 @@ func LogFatal(ctx context.Context, message string) {
|
|||||||
myLogger.Fatal(message)
|
myLogger.Fatal(message)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// LogPrintf prints a Print level message
|
||||||
|
func LogPrintf(ctx context.Context, format string, args ...interface{}) {
|
||||||
|
msg := fmt.Sprintf(format, args...)
|
||||||
|
myLogger := getLogger(ctx)
|
||||||
|
myLogger.Print(msg)
|
||||||
|
}
|
||||||
|
|
||||||
|
// LogTracef prints a Trace level message
|
||||||
|
func LogTracef(ctx context.Context, format string, args ...interface{}) {
|
||||||
|
msg := fmt.Sprintf(format, args...)
|
||||||
|
myLogger := getLogger(ctx)
|
||||||
|
myLogger.Trace(msg)
|
||||||
|
}
|
||||||
|
|
||||||
|
// LogDebugf prints a Debug level message
|
||||||
|
func LogDebugf(ctx context.Context, format string, args ...interface{}) {
|
||||||
|
msg := fmt.Sprintf(format, args...)
|
||||||
|
myLogger := getLogger(ctx)
|
||||||
|
myLogger.Debug(msg)
|
||||||
|
}
|
||||||
|
|
||||||
|
// LogInfof prints a Info level message
|
||||||
|
func LogInfof(ctx context.Context, format string, args ...interface{}) {
|
||||||
|
msg := fmt.Sprintf(format, args...)
|
||||||
|
myLogger := getLogger(ctx)
|
||||||
|
myLogger.Info(msg)
|
||||||
|
}
|
||||||
|
|
||||||
|
// LogWarningf prints a Warning level message
|
||||||
|
func LogWarningf(ctx context.Context, format string, args ...interface{}) {
|
||||||
|
msg := fmt.Sprintf(format, args...)
|
||||||
|
myLogger := getLogger(ctx)
|
||||||
|
myLogger.Warning(msg)
|
||||||
|
}
|
||||||
|
|
||||||
|
// LogErrorf prints a Error level message
|
||||||
|
func LogErrorf(ctx context.Context, format string, args ...interface{}) {
|
||||||
|
msg := fmt.Sprintf(format, args...)
|
||||||
|
myLogger := getLogger(ctx)
|
||||||
|
myLogger.Error(msg)
|
||||||
|
}
|
||||||
|
|
||||||
|
// LogFatalf prints a Fatal level message
|
||||||
|
func LogFatalf(ctx context.Context, format string, args ...interface{}) {
|
||||||
|
msg := fmt.Sprintf(format, args...)
|
||||||
|
myLogger := getLogger(ctx)
|
||||||
|
myLogger.Fatal(msg)
|
||||||
|
}
|
||||||
|
|
||||||
// LogSetLogLevel sets the log level
|
// LogSetLogLevel sets the log level
|
||||||
func LogSetLogLevel(ctx context.Context, level logger.LogLevel) {
|
func LogSetLogLevel(ctx context.Context, level logger.LogLevel) {
|
||||||
myLogger := getLogger(ctx)
|
myLogger := getLogger(ctx)
|
||||||
|
@ -27,6 +27,12 @@ JS Signature: `LogPrint(message: string)`
|
|||||||
|
|
||||||
Logs the given message as a raw message.
|
Logs the given message as a raw message.
|
||||||
|
|
||||||
|
### LogPrintf
|
||||||
|
|
||||||
|
Go Signature: `LogPrintf(ctx context.Context, format string, args ...interface{})`
|
||||||
|
|
||||||
|
Logs the given message as a raw message.
|
||||||
|
|
||||||
### LogTrace
|
### LogTrace
|
||||||
|
|
||||||
Go Signature: `LogTrace(ctx context.Context, message string)`
|
Go Signature: `LogTrace(ctx context.Context, message string)`
|
||||||
@ -35,6 +41,12 @@ JS Signature: `LogTrace(message: string)`
|
|||||||
|
|
||||||
Logs the given message at the `Trace` log level.
|
Logs the given message at the `Trace` log level.
|
||||||
|
|
||||||
|
### LogTracef
|
||||||
|
|
||||||
|
Go Signature: `LogTracef(ctx context.Context, format string, args ...interface{})`
|
||||||
|
|
||||||
|
Logs the given message at the `Trace` log level.
|
||||||
|
|
||||||
### LogDebug
|
### LogDebug
|
||||||
|
|
||||||
Go Signature: `LogDebug(ctx context.Context, message string)`
|
Go Signature: `LogDebug(ctx context.Context, message string)`
|
||||||
@ -43,6 +55,11 @@ JS Signature: `LogDebug(message: string)`
|
|||||||
|
|
||||||
Logs the given message at the `Debug` log level.
|
Logs the given message at the `Debug` log level.
|
||||||
|
|
||||||
|
### LogDebugf
|
||||||
|
|
||||||
|
Go Signature: `LogDebugf(ctx context.Context, format string, args ...interface{})`
|
||||||
|
|
||||||
|
Logs the given message at the `Debug` log level.
|
||||||
|
|
||||||
### LogInfo
|
### LogInfo
|
||||||
|
|
||||||
@ -52,6 +69,11 @@ JS Signature: `LogInfo(message: string)`
|
|||||||
|
|
||||||
Logs the given message at the `Info` log level.
|
Logs the given message at the `Info` log level.
|
||||||
|
|
||||||
|
### LogInfof
|
||||||
|
|
||||||
|
Go Signature: `LogInfof(ctx context.Context, format string, args ...interface{})`
|
||||||
|
|
||||||
|
Logs the given message at the `Info` log level.
|
||||||
|
|
||||||
### LogWarning
|
### LogWarning
|
||||||
|
|
||||||
@ -61,6 +83,11 @@ JS Signature: `LogWarning(message: string)`
|
|||||||
|
|
||||||
Logs the given message at the `Warning` log level.
|
Logs the given message at the `Warning` log level.
|
||||||
|
|
||||||
|
### LogWarningf
|
||||||
|
|
||||||
|
Go Signature: `LogWarningf(ctx context.Context, format string, args ...interface{})`
|
||||||
|
|
||||||
|
Logs the given message at the `Warning` log level.
|
||||||
|
|
||||||
### LogError
|
### LogError
|
||||||
|
|
||||||
@ -70,14 +97,26 @@ JS Signature: `LogError(message: string)`
|
|||||||
|
|
||||||
Logs the given message at the `Error` log level.
|
Logs the given message at the `Error` log level.
|
||||||
|
|
||||||
|
### LogErrorf
|
||||||
|
|
||||||
|
Go Signature: `LogErrorf(ctx context.Context, format string, args ...interface{})`
|
||||||
|
|
||||||
|
Logs the given message at the `Error` log level.
|
||||||
|
|
||||||
### LogFatal
|
### LogFatal
|
||||||
|
|
||||||
Go Signature: `LogFatal(ctx context.Context, message string)`
|
Go Signature: `LogFatal(ctx context.Context, message string)`
|
||||||
|
|
||||||
JS Signature: `LogFatal(message: string)`
|
JS Signature: `LogFatal(message: string)`
|
||||||
|
|
||||||
Logs the given message at the `Fatal` log level.
|
Logs the given message at the `Fatal` log level.
|
||||||
|
|
||||||
|
### LogFatalf
|
||||||
|
|
||||||
|
Go Signature: `LogFatalf(ctx context.Context, format string, args ...interface{})`
|
||||||
|
|
||||||
|
Logs the given message at the `Fatal` log level.
|
||||||
|
|
||||||
### LogSetLogLevel
|
### LogSetLogLevel
|
||||||
|
|
||||||
Go Signature: `LogSetLogLevel(ctx context.Context, level logger.LogLevel)`
|
Go Signature: `LogSetLogLevel(ctx context.Context, level logger.LogLevel)`
|
||||||
|
Loading…
Reference in New Issue
Block a user