github.com/choria-io/go-choria@v0.28.1-0.20240416190746-b3bf9c7d5a45/aagent/notifiers/console/console.go (about) 1 // Copyright (c) 2019-2022, R.I. Pienaar and the Choria Project contributors 2 // 3 // SPDX-License-Identifier: Apache-2.0 4 5 // Package console is a NotificationService that logs to the console 6 package console 7 8 import ( 9 "fmt" 10 11 "github.com/choria-io/go-choria/aagent/machine" 12 "github.com/sirupsen/logrus" 13 ) 14 15 // Notifier implements machine.NotificationService 16 type Notifier struct{} 17 18 // Debugf implements machine.NotificationService 19 func (n *Notifier) Debugf(m machine.InfoSource, name string, format string, args ...any) { 20 logrus.Debugf("%s#%s: %s", m.Name(), name, fmt.Sprintf(format, args...)) 21 } 22 23 // Infof implements machine.NotificationService 24 func (n *Notifier) Infof(m machine.InfoSource, name string, format string, args ...any) { 25 logrus.Infof("%s#%s: %s", m.Name(), name, fmt.Sprintf(format, args...)) 26 } 27 28 // Warnf implements machine.NotificationService 29 func (n *Notifier) Warnf(m machine.InfoSource, name string, format string, args ...any) { 30 logrus.Warnf("%s#%s: %s", m.Name(), name, fmt.Sprintf(format, args...)) 31 } 32 33 // Errorf implements machine.NotificationService 34 func (n *Notifier) Errorf(m machine.InfoSource, name string, format string, args ...any) { 35 logrus.Errorf("%s#%s: %s", m.Name(), name, fmt.Sprintf(format, args...)) 36 } 37 38 // NotifyPostTransition implements machine.NotificationService 39 func (n *Notifier) NotifyPostTransition(transition *machine.TransitionNotification) error { 40 logrus.Infof("%s transitioned via event %s: %s => %s", transition.Machine, transition.Transition, transition.FromState, transition.ToState) 41 42 return nil 43 } 44 45 // NotifyWatcherState implements machine.NotificationService 46 func (n *Notifier) NotifyWatcherState(name string, detail machine.WatcherStateNotification) error { 47 logrus.Info(detail.String()) 48 49 return nil 50 }