make time formatting be optional

main
Brian Picciano 2 years ago
parent 2c5c669c72
commit ea5e7c9e1c
  1. 17
      main.go
  2. 2
      pmux-example.yml

@ -135,11 +135,18 @@ func (l *logger) println(line string) {
l.l.Lock()
defer l.l.Unlock()
if l.timeFmt != "" {
fmt.Fprintf(
l.outBuf,
"%s %c ",
time.Now().Format(l.timeFmt),
l.sep,
)
}
fmt.Fprintf(
l.outBuf,
"%s %c %s%s%c %s\n",
time.Now().Format(l.timeFmt),
l.sep,
"%s%s%c %s\n",
l.pname,
strings.Repeat(" ", int(*l.maxPNameLen+1)-len(l.pname)),
l.sep,
@ -167,10 +174,6 @@ type config struct {
func (cfg config) init() (config, error) {
if cfg.TimeFormat == "" {
cfg.TimeFormat = "2006-01-02T15:04:05.000Z07:00"
}
if len(cfg.Processes) == 0 {
return config{}, errors.New("no processes defined")
}

@ -3,6 +3,8 @@
# timeFormat defines the formatting of timestamps. See
# https://pkg.go.dev/time#pkg-constants for more info on how the formatting
# string works.
#
# If timeFormat isn't set then the time is not included in each log line.
timeFormat: "2006-01-02T15:04:05.000Z07:00"
# processes is the only required field, it must have at least one process

Loading…
Cancel
Save