logpolicy: directly expose the logtail server URL (#5788)

Callers of LogHost often jump through hoops to undo the
loss of information dropped by LogHost (e.g., the HTTP scheme).

Signed-off-by: Joe Tsai <joetsai@digital-static.net>
This commit is contained in:
Joe Tsai 2022-09-29 13:28:51 -07:00 committed by GitHub
parent bb7be74756
commit e73657d7aa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 0 deletions

View File

@ -70,8 +70,19 @@ func getLogTarget() string {
return getLogTargetOnce.v
}
// LogURL is the base URL for the configured logtail server, or the default.
// It is guaranteed to not terminate with any forward slashes.
func LogURL() string {
if v := getLogTarget(); v != "" {
return strings.TrimRight(v, "/")
}
return "https://" + logtail.DefaultHost
}
// LogHost returns the hostname only (without port) of the configured
// logtail server, or the default.
//
// Deprecated: Use LogURL instead.
func LogHost() string {
if v := getLogTarget(); v != "" {
if u, err := url.Parse(v); err == nil {