(fnType logFunctionType, message string)
| 275 | } |
| 276 | |
| 277 | func (s *StreamLogger) writeMessage(fnType logFunctionType, message string) { |
| 278 | fnInformation := fnTypeInformationMap[fnType] |
| 279 | message = s.writePrefixes(message) |
| 280 | for _, s := range s.sinks { |
| 281 | if fnInformation.logLevel == logrus.PanicLevel || fnInformation.logLevel == logrus.FatalLevel { |
| 282 | s.Print(logrus.ErrorLevel, message) |
| 283 | } else { |
| 284 | s.Print(fnInformation.logLevel, message) |
| 285 | } |
| 286 | } |
| 287 | |
| 288 | if s.level >= fnInformation.logLevel { |
| 289 | stream := s.getStream(fnInformation.logLevel) |
| 290 | if s.format == RawFormat { |
| 291 | _, _ = stream.Write([]byte(message)) |
| 292 | } else if s.format == TimeFormat { |
| 293 | if env.GlobalGetEnv(DevSpaceLogTimestamps) == "true" || s.level == logrus.DebugLevel { |
| 294 | now := time.Now() |
| 295 | _, _ = stream.Write([]byte(ansi.Color(formatInt(now.Hour())+":"+formatInt(now.Minute())+":"+formatInt(now.Second())+" ", "white+b"))) |
| 296 | } |
| 297 | _, _ = stream.Write([]byte(message)) |
| 298 | } else if s.format == TextFormat { |
| 299 | if env.GlobalGetEnv(DevSpaceLogTimestamps) == "true" || s.level == logrus.DebugLevel { |
| 300 | now := time.Now() |
| 301 | _, _ = stream.Write([]byte(ansi.Color(formatInt(now.Hour())+":"+formatInt(now.Minute())+":"+formatInt(now.Second())+" ", "white+b"))) |
| 302 | } |
| 303 | _, _ = stream.Write([]byte(ansi.Color(fnInformation.tag, fnInformation.color))) |
| 304 | _, _ = stream.Write([]byte(message)) |
| 305 | } else if s.format == JSONFormat { |
| 306 | s.writeJSON(message, fnInformation.logLevel) |
| 307 | } |
| 308 | } |
| 309 | } |
| 310 | |
| 311 | func (s *StreamLogger) writeJSON(message string, level logrus.Level) { |
| 312 | stream := s.getStream(level) |
no test coverage detected