INNER CODE UNIT · Go

LoadGlobalConfig

alibaba/loongcollector · plugin_main/plugin_export.go:148

func LoadGlobalConfig(jsonStr string) int {
	// Only the first call will return non-zero.
	retcode := 0
	loadOnce.Do(func() {
		if len(jsonStr) >= 2 { // For invalid JSON, use default value and return 0
			if err := json.Unmarshal([]byte(jsonStr), &config.LoongcollectorGlobalConfig); err != nil {
				fmt.Println("load global config error", "GlobalConfig", jsonStr, "err", err)
				retcode = 1
			}
			logger.InitLogger()
			for _, log := range flags.LogsWaitToPrint {
				switch log.LogType {
				case flags.LogTypeError:
					logger.Error(context.Background(), log.AlarmType, log.Content)
				case flags.LogTypeInfo:
					logger.Info(context.Background(), log.Content)
				case flags.LogTypeDebug:
					logger.Debug(context.Background(), log.Content)

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…