func Elapsed(j LoggableJob) int64 {
	now := time.Now().UnixNano() / int64(time.Millisecond)
	created := int64(j.CreatedAt())
	return now - created
}
Elapsed returns elapsed since the job is created in millisecond.
package logger
import (
	"os"
	"time"
	"github.com/fireworq/fireworq/config"
	logwriter "github.com/fireworq/fireworq/log"
	"github.com/rs/zerolog"
	"github.com/rs/zerolog/log"
)
var (
	Writer = logwriter.New(os.Stdout)
	tag    string
	logger *zerolog.Logger = func() *zerolog.Logger {
		l := zerolog.Nop()
		return &l
	}()
)
func Init() {
	tag = config.Get("queue_log_tag")
	output := config.Get("queue_log")
	if len(output) > 0 {
		log.Info().Msgf("Queue log file: %s", output)
		w, err := logwriter.OpenFile(output)
		if err != nil {
			log.Panic().Msg(err.Error())
		}
		Writer = w
	}
	level := logwriter.ParseLevel(config.Get("queue_log_level"), zerolog.InfoLevel)
	l := zerolog.New(Writer).With().Logger().Level(level)
	logger = &l
}
func put(event *zerolog.Event, queue string, action string, j LoggableJob, msg string) {
	created := int64(j.CreatedAt())
	elapsed := Elapsed(j)
	event.
		Int64("time", created+elapsed).
		Str("tag", tag).
		Str("action", action).
		Str("queue", queue).
		Str("category", j.Category()).
		Uint64("id", j.ID()).
		Str("status", j.Status()).
		Int64("created_at", created).
		Int64("elapsed", elapsed).
		Str("url", j.URL()).
		Str("payload", j.Payload()).
		Uint64("next_try", j.NextTry()).
		Uint("retry_count", j.RetryCount()).
		Uint("retry_delay", j.RetryDelay()).
		Uint("fail_count", j.FailCount()).
		Uint("timeout", j.Timeout()).
		Msg(msg)
}
func Info(queue string, action string, j LoggableJob, msg string) {
	put(logger.Info(), queue, action, j, msg)
}
func Debug(queue string, action string, j LoggableJob, msg string) {
	put(logger.Debug(), queue, action, j, msg)
}
type LoggableJob interface {
	Category() string
	URL() string
	Payload() string
	ID() uint64
	Status() string
	NextTry() uint64
	RetryCount() uint
	RetryDelay() uint
	FailCount() uint
	Timeout() uint
	CreatedAt() uint64
}