package com.fs.common.utils;

import cn.hutool.core.lang.UUID;
import org.slf4j.MDC;

public class TraceIdUtil {

    private static final String TRACK_ID_KEY = "X-Track-Id";

    public static void init() {
        String trackId = UUID.randomUUID().toString().replace("-", "");
        MDC.put(TRACK_ID_KEY, trackId);
    }

    public static void clear() {
        MDC.remove(TRACK_ID_KEY);
    }

    public static String get() {
        return MDC.get(TRACK_ID_KEY);
    }

    public static void put(String key) {
        MDC.put(TRACK_ID_KEY, key);
    }
}
