package cn.reghao.tnb.content.app.vod.service;

import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.cloud.context.environment.EnvironmentChangeEvent;
import org.springframework.context.ApplicationContext;
import org.springframework.context.event.EventListener;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

/**
 * @author reghao
 * @date 2025-04-18 14:45:36
 */
@RefreshScope
@Service
@Deprecated
public class LogService {
    //private final LogProperties logProperties;

    public LogService() {
    }

    public Map<String, Object> getLogProperties() {
        Map<String, Object> map = new HashMap<>();
        /*map.put("enabled", enabled);
        map.put("wsUrl", wsUrl);
        map.put("token", token);*/
        return map;
    }

    @EventListener
    public void envListener(EnvironmentChangeEvent event) {
        ApplicationContext context = (ApplicationContext) event.getSource();
        Environment environment = context.getEnvironment();
        Set<String> changedKeys = event.getKeys();
        System.out.println("changed keys -> " + changedKeys);
        for (String key : changedKeys) {
            String value = environment.getProperty(key);
            System.out.printf("new value %s -> %s", key, value);
        }
    }
}
