(w http.ResponseWriter, r *http.Request)
| 1116 | } |
| 1117 | |
| 1118 | func (s *service) getSupportBundle(w http.ResponseWriter, r *http.Request) { |
| 1119 | var files []fileEntry |
| 1120 | const profilingDuration = 4 * time.Second |
| 1121 | |
| 1122 | // Redacted configuration as a JSON |
| 1123 | if jsonConfig, err := json.MarshalIndent(getRedactedConfig(s), "", " "); err != nil { |
| 1124 | slog.Warn("Failed to create config.json in support bundle", slogutil.Error(err)) |
| 1125 | } else { |
| 1126 | files = append(files, fileEntry{name: "config.json.txt", data: jsonConfig}) |
| 1127 | } |
| 1128 | |
| 1129 | // Log as a text |
| 1130 | var buflog bytes.Buffer |
| 1131 | for _, line := range s.systemLog.Since(time.Time{}) { |
| 1132 | fmt.Fprintf(&buflog, "%s: %s\n", line.When.Format(time.RFC3339), line.Message) |
| 1133 | } |
| 1134 | files = append(files, fileEntry{name: "log-inmemory.txt", data: buflog.Bytes()}) |
| 1135 | |
| 1136 | // Errors as a JSON |
| 1137 | if errs := s.guiErrors.Since(time.Time{}); len(errs) > 0 { |
| 1138 | if jsonError, err := json.MarshalIndent(errs, "", " "); err != nil { |
| 1139 | slog.Warn("Failed to create errors.json in support bundle", slogutil.Error(err)) |
| 1140 | } else { |
| 1141 | files = append(files, fileEntry{name: "errors.json.txt", data: jsonError}) |
| 1142 | } |
| 1143 | } |
| 1144 | |
| 1145 | // Panic files |
| 1146 | if panicFiles, err := filepath.Glob(filepath.Join(locations.GetBaseDir(locations.ConfigBaseDir), "panic*")); err == nil { |
| 1147 | for _, f := range panicFiles { |
| 1148 | if panicFile, err := os.ReadFile(f); err != nil { |
| 1149 | slog.Warn("Failed to load panic file for support bundle", slogutil.FilePath(filepath.Base(f)), slogutil.Error(err)) |
| 1150 | } else { |
| 1151 | files = append(files, fileEntry{name: filepath.Base(f), data: panicFile}) |
| 1152 | } |
| 1153 | } |
| 1154 | } |
| 1155 | |
| 1156 | // Archived log (default on Windows) |
| 1157 | if logFile, err := os.ReadFile(locations.Get(locations.LogFile)); err == nil { |
| 1158 | files = append(files, fileEntry{name: "log-ondisk.txt", data: logFile}) |
| 1159 | } |
| 1160 | |
| 1161 | // Version and platform information as a JSON |
| 1162 | if versionPlatform, err := json.MarshalIndent(map[string]string{ |
| 1163 | "now": time.Now().Format(time.RFC3339), |
| 1164 | "version": build.Version, |
| 1165 | "codename": build.Codename, |
| 1166 | "longVersion": build.LongVersion, |
| 1167 | "os": runtime.GOOS, |
| 1168 | "arch": runtime.GOARCH, |
| 1169 | }, "", " "); err == nil { |
| 1170 | files = append(files, fileEntry{name: "version-platform.json.txt", data: versionPlatform}) |
| 1171 | } else { |
| 1172 | slog.Warn("Failed to create versionPlatform.json in support bundle", slogutil.Error(err)) |
| 1173 | } |
| 1174 | |
| 1175 | // Report Data as a JSON |
nothing calls this directly
no test coverage detected