MCPcopy Index your code
hub / github.com/cloudflare/cloudflared / GetLogConfiguration

Method GetLogConfiguration

diagnostic/client.go:66–102  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

64}
65
66func (client *httpClient) GetLogConfiguration(ctx context.Context) (*LogConfiguration, error) {
67 response, err := client.GET(ctx, cliConfigurationEndpoint)
68 if err != nil {
69 return nil, err
70 }
71
72 defer response.Body.Close()
73
74 var data map[string]string
75 if err := json.NewDecoder(response.Body).Decode(&data); err != nil {
76 return nil, fmt.Errorf("failed to decode body: %w", err)
77 }
78
79 uidStr, exists := data[configurationKeyUID]
80 if !exists {
81 return nil, ErrKeyNotFound
82 }
83
84 uid, err := strconv.Atoi(uidStr)
85 if err != nil {
86 return nil, fmt.Errorf("error convertin pid to int: %w", err)
87 }
88
89 logFile, exists := data[cfdflags.LogFile]
90 if exists {
91 return &LogConfiguration{logFile, "", uid}, nil
92 }
93
94 logDirectory, exists := data[cfdflags.LogDirectory]
95 if exists {
96 return &LogConfiguration{"", logDirectory, uid}, nil
97 }
98
99 // No log configured may happen when cloudflared is executed as a managed service or
100 // when containerized
101 return &LogConfiguration{"", "", uid}, nil
102}
103
104func (client *httpClient) GetMemoryDump(ctx context.Context, writer io.Writer) error {
105 response, err := client.GET(ctx, memoryDumpEndpoint)

Callers

nothing calls this directly

Calls 4

GETMethod · 0.95
ErrorfMethod · 0.80
CloseMethod · 0.65
DecodeMethod · 0.45

Tested by

no test coverage detected