[GH-ISSUE #659] [BUG] The time displayed after starting the project is not the local time, but the world time #326

Open
opened 2026-03-02 05:20:29 +03:00 by kerem · 6 comments
Owner

Originally created by @jbhvip on GitHub (May 15, 2023).
Original GitHub issue: https://github.com/hibiken/asynq/issues/659

Originally assigned to: @hibiken on GitHub.

asynq: pid=65973 2023/05/15 19:38:02.726677 INFO: Starting processing
asynq: pid=65973 2023/05/15 19:38:02.726691 INFO: Send signal TSTP to stop processing new tasks
asynq: pid=65973 2023/05/15 19:38:02.726693 INFO: Send signal TERM or INT to terminate the process

The time displayed after starting the project is not the local time, but the world time. How to modify this, there is no place to modify it, and it cannot be modified to the time in the specified time zone

Originally created by @jbhvip on GitHub (May 15, 2023). Original GitHub issue: https://github.com/hibiken/asynq/issues/659 Originally assigned to: @hibiken on GitHub. asynq: pid=65973 2023/05/15 19:38:02.726677 INFO: Starting processing asynq: pid=65973 2023/05/15 19:38:02.726691 INFO: Send signal TSTP to stop processing new tasks asynq: pid=65973 2023/05/15 19:38:02.726693 INFO: Send signal TERM or INT to terminate the process The time displayed after starting the project is not the local time, but the world time. How to modify this, there is no place to modify it, and it cannot be modified to the time in the specified time zone
Author
Owner

@xmwilldo commented on GitHub (Jun 20, 2023):

I have the same problem

<!-- gh-comment-id:1598161467 --> @xmwilldo commented on GitHub (Jun 20, 2023): I have the same problem
Author
Owner

@xuyang2 commented on GitHub (Jun 20, 2023):

package asynqzaplog

import (
	"github.com/hibiken/asynq"
	"go.uber.org/zap"
)

var _ asynq.Logger = (*zap.SugaredLogger)(nil)
var _ asynq.Logger = (*Logger)(nil)

func Wrap(logger *zap.Logger) asynq.Logger {
	l := logger.WithOptions(zap.AddCallerSkip(2)).Sugar()
	return &Logger{l: l}
}

type Logger struct {
	l asynq.Logger
}

func (l *Logger) Debug(args ...interface{}) {
	l.l.Debug(args...)
}

func (l *Logger) Info(args ...interface{}) {
	l.l.Info(args...)
}

func (l *Logger) Warn(args ...interface{}) {
	l.l.Warn(args...)
}

func (l *Logger) Error(args ...interface{}) {
	l.l.Error(args...)
}

func (l *Logger) Fatal(args ...interface{}) {
	l.l.Fatal(args...)
}

main.go:

var logger *zap.Logger
...
asynqLogger := asynqzaplog.Wrap(logger)
opt := &asynq.SchedulerOpts{
	...
	Logger:              asynqLogger,
	...
}
redisOpt = ...
asynq.NewScheduler(redisOpt, opt)
<!-- gh-comment-id:1598172125 --> @xuyang2 commented on GitHub (Jun 20, 2023): ```go package asynqzaplog import ( "github.com/hibiken/asynq" "go.uber.org/zap" ) var _ asynq.Logger = (*zap.SugaredLogger)(nil) var _ asynq.Logger = (*Logger)(nil) func Wrap(logger *zap.Logger) asynq.Logger { l := logger.WithOptions(zap.AddCallerSkip(2)).Sugar() return &Logger{l: l} } type Logger struct { l asynq.Logger } func (l *Logger) Debug(args ...interface{}) { l.l.Debug(args...) } func (l *Logger) Info(args ...interface{}) { l.l.Info(args...) } func (l *Logger) Warn(args ...interface{}) { l.l.Warn(args...) } func (l *Logger) Error(args ...interface{}) { l.l.Error(args...) } func (l *Logger) Fatal(args ...interface{}) { l.l.Fatal(args...) } ``` main.go: ```go var logger *zap.Logger ... asynqLogger := asynqzaplog.Wrap(logger) opt := &asynq.SchedulerOpts{ ... Logger: asynqLogger, ... } redisOpt = ... asynq.NewScheduler(redisOpt, opt) ```
Author
Owner

@xmwilldo commented on GitHub (Jun 20, 2023):

???

<!-- gh-comment-id:1598201209 --> @xmwilldo commented on GitHub (Jun 20, 2023): ???
Author
Owner

@jbhvip commented on GitHub (Jun 20, 2023):

package asynqzaplog

import (
	"github.com/hibiken/asynq"
	"go.uber.org/zap"
)

var _ asynq.Logger = (*zap.SugaredLogger)(nil)
var _ asynq.Logger = (*Logger)(nil)

func Wrap(logger *zap.Logger) asynq.Logger {
	l := logger.WithOptions(zap.AddCallerSkip(2)).Sugar()
	return &Logger{l: l}
}

type Logger struct {
	l asynq.Logger
}

func (l *Logger) Debug(args ...interface{}) {
	l.l.Debug(args...)
}

func (l *Logger) Info(args ...interface{}) {
	l.l.Info(args...)
}

func (l *Logger) Warn(args ...interface{}) {
	l.l.Warn(args...)
}

func (l *Logger) Error(args ...interface{}) {
	l.l.Error(args...)
}

func (l *Logger) Fatal(args ...interface{}) {
	l.l.Fatal(args...)
}

主要去:

var logger *zap.Logger
...
asynqLogger := asynqzaplog.Wrap(logger)
opt := &asynq.SchedulerOpts{
	...
	Logger:              asynqLogger,
	...
}
redisOpt = ...
asynq.NewScheduler(redisOpt, opt)

我试试

<!-- gh-comment-id:1598204274 --> @jbhvip commented on GitHub (Jun 20, 2023): > ```go > package asynqzaplog > > import ( > "github.com/hibiken/asynq" > "go.uber.org/zap" > ) > > var _ asynq.Logger = (*zap.SugaredLogger)(nil) > var _ asynq.Logger = (*Logger)(nil) > > func Wrap(logger *zap.Logger) asynq.Logger { > l := logger.WithOptions(zap.AddCallerSkip(2)).Sugar() > return &Logger{l: l} > } > > type Logger struct { > l asynq.Logger > } > > func (l *Logger) Debug(args ...interface{}) { > l.l.Debug(args...) > } > > func (l *Logger) Info(args ...interface{}) { > l.l.Info(args...) > } > > func (l *Logger) Warn(args ...interface{}) { > l.l.Warn(args...) > } > > func (l *Logger) Error(args ...interface{}) { > l.l.Error(args...) > } > > func (l *Logger) Fatal(args ...interface{}) { > l.l.Fatal(args...) > } > ``` > > 主要去: > > ```go > var logger *zap.Logger > ... > asynqLogger := asynqzaplog.Wrap(logger) > opt := &asynq.SchedulerOpts{ > ... > Logger: asynqLogger, > ... > } > redisOpt = ... > asynq.NewScheduler(redisOpt, opt) > ``` 我试试
Author
Owner

@jbhvip commented on GitHub (Jun 20, 2023):

Not resolved, don't know how to resolve this situation

<!-- gh-comment-id:1598249026 --> @jbhvip commented on GitHub (Jun 20, 2023): Not resolved, don't know how to resolve this situation
Author
Owner

@ioannidesalex commented on GitHub (Jul 8, 2023):

Same as #671

<!-- gh-comment-id:1627532282 --> @ioannidesalex commented on GitHub (Jul 8, 2023): Same as #671
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/asynq#326
No description provided.