feat(cmd/joj3): more random runID
This commit is contained in:
		
							parent
							
								
									e4bfcfbe8d
								
							
						
					
					
						commit
						ea75e992aa
					
				|  | @ -5,7 +5,6 @@ import ( | ||||||
| 	"fmt" | 	"fmt" | ||||||
| 	"log/slog" | 	"log/slog" | ||||||
| 	"os" | 	"os" | ||||||
| 	"strconv" |  | ||||||
| 	"time" | 	"time" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
|  | @ -18,9 +17,16 @@ type multiHandler struct { | ||||||
| var runID string | var runID string | ||||||
| 
 | 
 | ||||||
| func init() { | func init() { | ||||||
| 	runID = fmt.Sprintf("%06s%04s", | 	timestamp := time.Now().UnixNano() | ||||||
| 		strconv.FormatInt(time.Now().Unix(), 36), | 	pid := os.Getpid() | ||||||
| 		strconv.FormatInt(int64(os.Getpid()), 36)) | 	high := timestamp >> 32 | ||||||
|  | 	low := timestamp & 0xFFFFFFFF | ||||||
|  | 	combined := high ^ low | ||||||
|  | 	combined ^= int64(pid) | ||||||
|  | 	combined ^= int64(timestamp >> 16) | ||||||
|  | 	combined ^= (combined >> 8) | ||||||
|  | 	combined ^= (combined << 16) | ||||||
|  | 	runID = fmt.Sprintf("%08X", combined&0xFFFFFFFF) | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func (h *multiHandler) Enabled(ctx context.Context, level slog.Level) bool { | func (h *multiHandler) Enabled(ctx context.Context, level slog.Level) bool { | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user