Documentation ¶
Index ¶
- Constants
- func CreateDatedLogFile(directory, prefix string) (*os.File, error)
- func CreateDatedLogFileCtx(ctx context.Context, directory, prefix string) (*os.File, error)
- func CreateDatedLogFileFormatted(directory, prefix string, format string) (*os.File, error)
- func CreateDatedLogFileFormattedCtx(ctx context.Context, directory, prefix string, format string) (*os.File, error)
- func DisableSyncErrorAccounting()
- func EnableSyncErrorAccounting()
- func StartPeriodicSync(ctx context.Context, f *os.File, dur time.Duration)
- type Log
Examples ¶
Constants ¶
const MaximumSyncErrors = 10000
Variables ¶
This section is empty.
Functions ¶
func CreateDatedLogFileCtx ¶
func DisableSyncErrorAccounting ¶
func DisableSyncErrorAccounting()
DisableSyncErrorAccounting disables storing and panicking upon exceeding the maximum sync error constant with regard to log files created with [CreateDatedLogfile] and managed by StartPeriodicSync. By default, this behavior is enabled.
func EnableSyncErrorAccounting ¶
func EnableSyncErrorAccounting()
EnableSyncErrorAccounting enables storing and panicking upon exceeding the maximum sync error constant with regard to log files created with [CreateDatedLogfile] and managed by StartPeriodicSync. By default, this behavior is enabled.
Types ¶
type Log ¶
type Log struct {
// contains filtered or unexported fields
}
func Global ¶
func Global() *Log
Global acquires the assigned global logger.
IMPORTANT: you MUST make your instance of Log globally accecible by calling [WithGlobalPackageAccess].
func NewLogger ¶
NewLogger creates a logger that writes to the given writers, as well as pretty prints to stdout.
Example ¶
f, _ := CreateDatedLogFile("./", "kayos_logger_example") log := NewLogger(f) log.C().SetPrefix(f.Name()) log.Z().Info().Msg("hello") log.C().Info("world") time.Sleep(50 * time.Millisecond)
Output:
func NewLoggerNoColor ¶
func NewQuietLogger ¶
NewQuietLogger creates a logger that writes to the given writers with no console writer added.
func (*Log) AddWriter ¶
AddWriter adds a writer to the logger.
Note: this may have unintended consequences if certain zwrap.Logger configuration values have been set via Log.C. That said, the zwrap.Logger prefix value will be preserved.
func (*Log) C ¶
func (l *Log) C() zwrap.ZWrapLogger
C returns a zwrap.ZWrapLogger which is a highly compattible interface to fit many other log intrefaces.
func (*Log) WithGlobalPackageAccess ¶
func (l *Log) WithGlobalPackageAccess()