GraphQL API and utilities for the rpdata project
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

20 lines
550 B

  1. package generate
  2. import (
  3. "fmt"
  4. "git.aiterp.net/rpdata/api/models"
  5. "time"
  6. )
  7. // LogID generates a log ID in the format is 2019-05-22_191341547_RedrockAgency
  8. func LogID(log models.Log) string {
  9. if len(log.ChannelName) < 1 {
  10. panic("ChannelName is not valid (validate input before calling this function!)")
  11. }
  12. datetime := log.Date.UTC().Format("2006-01-02_150405")
  13. milliseconds := (log.Date.UnixNano() % int64(time.Second)) / 1000000
  14. channelName := log.ChannelName[1:]
  15. return fmt.Sprintf("%s%03d_%s", datetime, milliseconds, channelName)
  16. }