logger

package
v0.0.0-...-ab2485f Latest Latest
Warning

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

Go to latest
Published: May 10, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Copyright 2025 AlaudaDevops authors

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EmojiLevelEncoder

func EmojiLevelEncoder(l zapcore.Level, enc zapcore.PrimitiveArrayEncoder)

EmojiLevelEncoder prints an emoji instead of the log level ❌ for Panic, Error and Fatal levels 🐛 for Debug ❗️ for Warning 📢 for Info and everything else

func GetLogLevel

func GetLogLevel(level string) zapcore.LevelEnabler

GetLogLevel returns a representation of the log level from a string

func GetLogger

func GetLogger(ctx context.Context) (logger *zap.SugaredLogger)

GetLogger get a logger instance form a context

func NewLogger

func NewLogger(writer zapcore.WriteSyncer, level zapcore.LevelEnabler, opts ...zap.Option) *zap.SugaredLogger

NewLogger construct a logger

func NewLoggerFromContext

func NewLoggerFromContext(ctx context.Context, level zapcore.LevelEnabler) (logger *zap.SugaredLogger)

NewLoggerFromContext similar to `GetLogger`, but return a default logger if there is no logger instance in the context

func WithLogger

func WithLogger(ctx context.Context, logger *zap.SugaredLogger) context.Context

WithLogger set a logger instance into a context

Types

type LogLeveler

type LogLeveler struct {
	Level string
}

LogLevel wrapper for zapcore.LevelEnabler

func (LogLeveler) Enabled

func (l LogLeveler) Enabled(level zapcore.Level) bool

Enabled implements zapcore.LevelEnabler to return true if a log level was implemented

Jump to

Keyboard shortcuts

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