Documentation ¶
Overview ¶
Package logruslogger is an Ambient plugin that provides log functionality using logrus.
Index ¶
- type Logger
- func (l *Logger) Debug(format string, v ...interface{})
- func (l *Logger) Error(format string, v ...interface{})
- func (l *Logger) Fatal(format string, v ...interface{})
- func (l *Logger) Info(format string, v ...interface{})
- func (l *Logger) Log(level ambient.LogLevel, format string, v ...interface{})
- func (l *Logger) Name() string
- func (l *Logger) Named(serviceName string) ambient.AppLogger
- func (l *Logger) SetLogLevel(level ambient.LogLevel)
- func (l *Logger) Warn(format string, v ...interface{})
- type Plugin
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger represents a logger.
func (*Logger) Debug ¶
Debug is equivalent to log.Printf() + "\n" if format is not empty. It's equivalent to Println() if format is empty.
func (*Logger) Error ¶
Error is equivalent to log.Printf() + "\n" if format is not empty. It's equivalent to Println() if format is empty.
func (*Logger) Fatal ¶
Fatal is equivalent to log.Printf() + "\n" if format is not empty. It's equivalent to Println() if format is empty. It's followed by a call to os.Exit(1).
func (*Logger) Info ¶
Info is equivalent to log.Printf() + "\n" if format is not empty. It's equivalent to Println() if format is empty.
func (*Logger) Log ¶
Log is equivalent to log.Printf() + "\n" if format is not empty. It's equivalent to Println() if format is empty.
func (*Logger) Named ¶
Named returns a new logger with the appended name, linked to the existing logger.
func (*Logger) SetLogLevel ¶
SetLogLevel will set the logger output level.
type Plugin ¶
type Plugin struct {
// contains filtered or unexported fields
}
Plugin represents an Ambient plugin.
func New ¶
func New() *Plugin
New returns an Ambient plugin that provides log functionality using logrus.
Example ¶
package main import ( "log" "github.com/ambientkit/ambient" "github.com/ambientkit/ambient/pkg/ambientapp" "github.com/ambientkit/plugin/logger/logruslogger" "github.com/ambientkit/plugin/storage/memorystorage" ) func main() { plugins := &ambient.PluginLoader{ // Core plugins are implicitly trusted. Router: nil, TemplateEngine: nil, SessionManager: nil, // Trusted plugins are those that are typically needed to boot so they // will be enabled and given full access. TrustedPlugins: map[string]bool{}, Plugins: []ambient.Plugin{}, Middleware: []ambient.MiddlewarePlugin{ // Middleware - executes top to bottom. }, } _, _, err := ambientapp.NewApp("myapp", "1.0", logruslogger.New(), ambient.StoragePluginGroup{ Storage: memorystorage.New(), }, plugins) if err != nil { log.Fatalln(err.Error()) } }
Output:
func (*Plugin) Logger ¶
func (p *Plugin) Logger(appName string, appVersion string, optionalWriter io.Writer) (ambient.AppLogger, error)
Logger returns a logger.
func (*Plugin) PluginName ¶
PluginName returns the plugin name.
func (*Plugin) PluginVersion ¶
PluginVersion returns the plugin version.