MCPcopy Create free account
hub / github.com/containerd/nerdctl / parseSyslogAddress

Function parseSyslogAddress

pkg/logging/syslog_logger.go:193–227  ·  view source on GitHub ↗
(address string)

Source from the content-addressed store, hash-verified

191}
192
193func parseSyslogAddress(address string) (string, string, error) {
194 if address == "" {
195 // Docker-compatible: fallback to `unix:///dev/log`,
196 // `unix:///var/run/syslog` or `unix:///var/run/log`. We do nothing
197 // with the empty address, just leave it here and the srslog will
198 // handle the fallback.
199 return "", "", nil
200 }
201 addr, err := url.Parse(address)
202 if err != nil {
203 return "", "", err
204 }
205
206 // unix and unixgram socket validation
207 if addr.Scheme == "unix" || addr.Scheme == "unixgram" {
208 if _, err := os.Stat(addr.Path); err != nil {
209 return "", "", err
210 }
211 return addr.Scheme, addr.Path, nil
212 }
213 if addr.Scheme != "udp" && addr.Scheme != "tcp" && addr.Scheme != syslogSecureProto {
214 return "", "", fmt.Errorf("unsupported scheme: '%s'", addr.Scheme)
215 }
216
217 // here we process tcp|udp
218 host := addr.Host
219 if _, _, err := net.SplitHostPort(host); err != nil {
220 if !strings.Contains(err.Error(), "missing port in address") {
221 return "", "", err
222 }
223 host = net.JoinHostPort(host, syslogDefaultPort)
224 }
225
226 return addr.Scheme, host, nil
227}
228
229func parseSyslogFacility(facility string) (syslog.Priority, error) {
230 if facility == "" {

Callers 2

SyslogOptsValidateFunction · 0.85
parseSyslogFunction · 0.85

Calls 3

StatMethod · 0.80
ParseMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…