github.com/mongodb/grip@v0.0.0-20240213223901-f906268d82b9/logging/general.go (about) 1 /* 2 Package logging provides the primary implementation of the Journaler 3 interface (which is cloned in public functions in the grip interface 4 itself.) 5 6 # Basic Logging 7 8 Loging helpers exist for the following levels: 9 10 Emergency + (fatal/panic) 11 Alert + (fatal/panic) 12 Critical + (fatal/panic) 13 Error + (fatal/panic) 14 Warning 15 Notice 16 Info 17 Debug 18 */ 19 package logging 20 21 import ( 22 "github.com/mongodb/grip/level" 23 "github.com/mongodb/grip/message" 24 ) 25 26 func (g *Grip) Log(l level.Priority, msg interface{}) { 27 g.send(message.ConvertToComposer(l, msg)) 28 } 29 func (g *Grip) Logf(l level.Priority, msg string, a ...interface{}) { 30 g.send(message.NewFormattedMessage(l, msg, a...)) 31 } 32 func (g *Grip) Logln(l level.Priority, a ...interface{}) { 33 g.send(message.NewLineMessage(l, a...)) 34 } 35 36 func (g *Grip) Emergency(msg interface{}) { 37 g.send(message.ConvertToComposer(level.Emergency, msg)) 38 } 39 func (g *Grip) Emergencyf(msg string, a ...interface{}) { 40 g.send(message.NewFormattedMessage(level.Emergency, msg, a...)) 41 } 42 func (g *Grip) Emergencyln(a ...interface{}) { 43 g.send(message.NewLineMessage(level.Emergency, a...)) 44 } 45 func (g *Grip) EmergencyPanic(msg interface{}) { 46 g.sendPanic(message.ConvertToComposer(level.Emergency, msg)) 47 } 48 func (g *Grip) EmergencyPanicf(msg string, a ...interface{}) { 49 g.sendPanic(message.NewFormattedMessage(level.Emergency, msg, a...)) 50 } 51 func (g *Grip) EmergencyPanicln(a ...interface{}) { 52 g.sendPanic(message.NewLineMessage(level.Emergency, a...)) 53 } 54 func (g *Grip) EmergencyFatal(msg interface{}) { 55 g.sendFatal(message.ConvertToComposer(level.Emergency, msg)) 56 } 57 func (g *Grip) EmergencyFatalf(msg string, a ...interface{}) { 58 g.sendFatal(message.NewFormattedMessage(level.Emergency, msg, a...)) 59 } 60 func (g *Grip) EmergencyFatalln(a ...interface{}) { 61 g.sendFatal(message.NewLineMessage(level.Emergency, a...)) 62 } 63 64 func (g *Grip) Alert(msg interface{}) { 65 g.send(message.ConvertToComposer(level.Alert, msg)) 66 } 67 func (g *Grip) Alertf(msg string, a ...interface{}) { 68 g.send(message.NewFormattedMessage(level.Alert, msg, a...)) 69 } 70 func (g *Grip) Alertln(a ...interface{}) { 71 g.send(message.NewLineMessage(level.Alert, a...)) 72 } 73 74 func (g *Grip) Critical(msg interface{}) { 75 g.send(message.ConvertToComposer(level.Critical, msg)) 76 } 77 func (g *Grip) Criticalf(msg string, a ...interface{}) { 78 g.send(message.NewFormattedMessage(level.Critical, msg, a...)) 79 } 80 func (g *Grip) Criticalln(a ...interface{}) { 81 g.send(message.NewLineMessage(level.Critical, a...)) 82 } 83 84 func (g *Grip) Error(msg interface{}) { 85 g.send(message.ConvertToComposer(level.Error, msg)) 86 } 87 func (g *Grip) Errorf(msg string, a ...interface{}) { 88 g.send(message.NewFormattedMessage(level.Error, msg, a...)) 89 } 90 func (g *Grip) Errorln(a ...interface{}) { 91 g.send(message.NewLineMessage(level.Error, a...)) 92 } 93 94 func (g *Grip) Warning(msg interface{}) { 95 g.send(message.ConvertToComposer(level.Warning, msg)) 96 } 97 func (g *Grip) Warningf(msg string, a ...interface{}) { 98 g.send(message.NewFormattedMessage(level.Warning, msg, a...)) 99 } 100 func (g *Grip) Warningln(a ...interface{}) { 101 g.send(message.NewLineMessage(level.Warning, a...)) 102 } 103 104 func (g *Grip) Notice(msg interface{}) { 105 g.send(message.ConvertToComposer(level.Notice, msg)) 106 } 107 func (g *Grip) Noticef(msg string, a ...interface{}) { 108 g.send(message.NewFormattedMessage(level.Notice, msg, a...)) 109 } 110 func (g *Grip) Noticeln(a ...interface{}) { 111 g.send(message.NewLineMessage(level.Notice, a...)) 112 } 113 114 func (g *Grip) Info(msg interface{}) { 115 g.send(message.ConvertToComposer(level.Info, msg)) 116 } 117 func (g *Grip) Infof(msg string, a ...interface{}) { 118 g.send(message.NewFormattedMessage(level.Info, msg, a...)) 119 } 120 func (g *Grip) Infoln(a ...interface{}) { 121 g.send(message.NewLineMessage(level.Info, a...)) 122 } 123 func (g *Grip) Debug(msg interface{}) { 124 g.send(message.ConvertToComposer(level.Debug, msg)) 125 } 126 func (g *Grip) Debugf(msg string, a ...interface{}) { 127 g.send(message.NewFormattedMessage(level.Debug, msg, a...)) 128 } 129 func (g *Grip) Debugln(a ...interface{}) { 130 g.send(message.NewLineMessage(level.Debug, a...)) 131 }