MCPcopy Create free account
hub / github.com/Masterminds/glide / Msg

Method Msg

msg/msg.go:159–190  ·  view source on GitHub ↗

Msg prints a message with optional arguments, that can be printed, of varying types.

(msg string, args ...interface{})

Source from the content-addressed store, hash-verified

157// Msg prints a message with optional arguments, that can be printed, of
158// varying types.
159func (m *Messenger) Msg(msg string, args ...interface{}) {
160 // When operations in Glide are happening concurrently messaging needs to be
161 // locked to avoid displaying one message in the middle of another one.
162 m.Lock()
163 defer m.Unlock()
164 // Get rid of the annoying fact that messages need \n at the end, but do
165 // it in a backward compatible way.
166 if !strings.HasSuffix(msg, "\n") {
167 msg += "\n"
168 }
169
170 if len(args) == 0 {
171 fmt.Fprint(m.Stderr, msg)
172 } else {
173 fmt.Fprintf(m.Stderr, msg, args...)
174 }
175
176 // If an arg is a vcs error print the output if in debug mode. This is
177 // capured here rather than calling Debug because concurrent operations
178 // could cause other messages to appear between the initial error and the
179 // debug output by unlocking and calling Debug.
180 if len(args) != 0 && !m.Quiet && m.IsDebugging {
181 if err, ok := args[len(args)-1].(error); ok {
182 switch t := err.(type) {
183 case *vcs.LocalError:
184 fmt.Fprintf(m.Stderr, "[DEBUG]\tOutput was: %s", strings.TrimSpace(t.Out()))
185 case *vcs.RemoteError:
186 fmt.Fprintf(m.Stderr, "[DEBUG]\tOutput was: %s", strings.TrimSpace(t.Out()))
187 }
188 }
189 }
190}
191
192// Msg prints a message with optional arguments, that can be printed, of
193// varying types using the Default Messenger.

Callers 6

InfoMethod · 0.95
DebugMethod · 0.95
WarnMethod · 0.95
ErrMethod · 0.95
mainFunction · 0.80
MsgFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected