src/server/pkg/log/log.go
func Pretty(entry *logrus.Entry) ([]byte, error) {
	serialized := []byte(
		fmt.Sprintf(
			"%v %v ",
			entry.Time.Format(logrus.DefaultTimestampFormat),
			strings.ToUpper(entry.Level.String()),
		),
	)
	if entry.Data["service"] != nil {
		serialized = append(serialized, []byte(fmt.Sprintf("%v.%v ", entry.Data["service"], entry.Data["method"]))...)
	}
	if len(entry.Data) > 2 {
		delete(entry.Data, "service")
		delete(entry.Data, "method")
		if entry.Data["duration"] != nil {
			entry.Data["duration"] = entry.Data["duration"].(time.Duration).Seconds()
		}
		data, err := json.Marshal(entry.Data)
		if err != nil {
			return nil, fmt.Errorf("Failed to marshal fields to JSON, %v", err)
		}
		serialized = append(serialized, []byte(string(data))...)
		serialized = append(serialized, ' ')
	}

	serialized = append(serialized, []byte(entry.Message)...)
	serialized = append(serialized, '\n')
	return serialized, nil
}
func Pretty(entry *logrus.Entry) ([]byte, error) {
	serialized := []byte(
		fmt.Sprintf(
			"%v %v ",
			entry.Time.Format(logrus.DefaultTimestampFormat),
			strings.ToUpper(entry.Level.String()),
		),
	)
	if entry.Data["service"] != nil {
		serialized = append(serialized, []byte(fmt.Sprintf("%v.%v ", entry.Data["service"], entry.Data["method"]))...)
	}
	if len(entry.Data) > 2 {
		delete(entry.Data, "service")
		delete(entry.Data, "method")
		if entry.Data["duration"] != nil {
			entry.Data["duration"] = entry.Data["duration"].(time.Duration).Seconds()
		}
		data, err := json.Marshal(entry.Data)
		if err != nil {
			return nil, fmt.Errorf("Failed to marshal fields to JSON, %v", err)
		}
		serialized = append(serialized, []byte(string(data))...)
		serialized = append(serialized, ' ')
	}

	serialized = append(serialized, []byte(entry.Message)...)
	serialized = append(serialized, '\n')
	return serialized, nil
}
func Pretty ( entry * logrus . Entry ) ( [ ] byte , error ) { serialized := [ ] byte ( fmt . Sprintf ( " " , entry . Time . Format ( logrus . DefaultTimestampFormat ) , strings . ToUpper ( entry . Level . String ( ) ) , ) , ) if entry . Data [ " " ] != nil { serialized = append ( serialized , [ ] byte ( fmt . Sprintf ( " " , entry . Data [ " " ] , entry . Data [ " " ] ) ) ... ) } if len ( entry . Data ) > 2 { delete ( entry . Data , " " ) delete ( entry . Data , " " ) if entry . Data [ " " ] != nil { entry . Data [ " " ] = entry . Data [ " " ] . ( time . Duration ) . Seconds ( ) } data , err := json . Marshal ( entry . Data ) if err != nil { return nil , fmt . Errorf ( " " , err ) } serialized = append ( serialized , [ ] byte ( string ( data ) ) ... ) serialized = append ( serialized , ' ' ) } serialized = append ( serialized , [ ] byte ( entry . Message ) ... ) serialized = append ( serialized , '\n' ) return serialized , nil }
// Pretty formats a logrus entry like so:
// ```
// 2019-02-11T16:02:02Z INFO pfs.API.InspectRepo {"request":{"repo":{"name":"images"}}} []
// ```
Pretty formats a logrus entry like so : 2019 - 02 - 11T16 : 02 : 02Z INFO pfs . API . InspectRepo { request : { repo : { name : images }}} []