Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cmd/boulder/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"flag"
"fmt"
"os"
"path"

_ "github.com/letsencrypt/boulder/cmd/admin-revoker"
_ "github.com/letsencrypt/boulder/cmd/akamai-purger"
Expand Down Expand Up @@ -32,6 +31,7 @@ import (
_ "github.com/letsencrypt/boulder/cmd/orphan-finder"
_ "github.com/letsencrypt/boulder/cmd/reversed-hostname-checker"
_ "github.com/letsencrypt/boulder/cmd/rocsp-tool"
"github.com/letsencrypt/boulder/core"

"github.com/letsencrypt/boulder/cmd"
)
Expand Down Expand Up @@ -61,7 +61,7 @@ func readAndValidateConfigFile(name, filename string) error {
}

func main() {
cmd.LookupCommand(path.Base(os.Args[0]))()
cmd.LookupCommand(core.Command())()
}

func init() {
Expand Down
15 changes: 5 additions & 10 deletions cmd/shell.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This package provides utilities that underlie the specific commands.
// Package cmd provides utilities that underlie the specific commands.
package cmd

import (
Expand All @@ -14,7 +14,6 @@ import (
"net/http/pprof"
"os"
"os/signal"
"path"
"runtime"
"strings"
"syscall"
Expand All @@ -40,10 +39,6 @@ import (
"github.com/letsencrypt/validator/v10"
)

func command() string {
return path.Base(os.Args[0])
}

// Because we don't know when this init will be called with respect to
// flag.Parse() and other flag definitions, we can't rely on the regular
// flag mechanism. But this one is fine.
Expand Down Expand Up @@ -198,7 +193,7 @@ func NewLogger(logConf SyslogConfig) blog.Logger {
"",
"",
syslog.LOG_INFO, // default, not actually used
command())
core.Command())
FailOnError(err, "Could not connect to Syslog")
syslogLevel := int(syslog.LOG_INFO)
if logConf.SyslogLevel != 0 {
Expand Down Expand Up @@ -245,7 +240,7 @@ func newVersionCollector() prometheus.Collector {
Name: "version",
Help: fmt.Sprintf(
"A metric with a constant value of '1' labeled by the short commit-id (buildId), build timestamp in RFC3339 format (buildTime), and Go release tag like 'go1.3' (goVersion) from which %s was built.",
command(),
core.Command(),
),
ConstLabels: prometheus.Labels{
"buildId": core.GetBuildID(),
Expand Down Expand Up @@ -310,7 +305,7 @@ func newOpenTelemetry(config OpenTelemetryConfig, logger blog.Logger) func(ctx c
resource.Default(),
resource.NewWithAttributes(
semconv.SchemaURL,
semconv.ServiceNameKey.String(command()),
semconv.ServiceNameKey.String(core.Command()),
semconv.ServiceVersionKey.String(core.GetBuildID()),
),
)
Expand Down Expand Up @@ -493,7 +488,7 @@ func ValidateYAMLConfig(cv *ConfigValidator, in io.Reader) error {

// VersionString produces a friendly Application version string.
func VersionString() string {
return fmt.Sprintf("Versions: %s=(%s %s) Golang=(%s) BuildHost=(%s)", command(), core.GetBuildID(), core.GetBuildTime(), runtime.Version(), core.GetBuildHost())
return fmt.Sprintf("Versions: %s=(%s %s) Golang=(%s) BuildHost=(%s)", core.Command(), core.GetBuildID(), core.GetBuildTime(), runtime.Version(), core.GetBuildHost())
}

// CatchSignals blocks until a SIGTERM, SIGINT, or SIGHUP is received, then
Expand Down
5 changes: 5 additions & 0 deletions core/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"math/big"
mrand "math/rand"
"os"
"path"
"reflect"
"regexp"
"sort"
Expand Down Expand Up @@ -298,3 +299,7 @@ func IsASCII(str string) bool {
}
return true
}

func Command() string {
return path.Base(os.Args[0])
}
7 changes: 4 additions & 3 deletions log/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@ import (
"io"
"log/syslog"
"os"
"path"
"runtime"
"strings"
"sync"

"github.com/jmhodges/clock"
"golang.org/x/term"

"github.com/letsencrypt/boulder/core"
)

// A Logger logs messages with explicit priority levels. It is
Expand Down Expand Up @@ -92,7 +93,7 @@ func newStdoutWriter(level int) *stdoutWriter {
}
}

prefix := fmt.Sprintf("%s %s %s[%d]:", shortHostname, datacenter, path.Base(os.Args[0]), os.Getpid())
prefix := fmt.Sprintf("%s %s %s[%d]:", shortHostname, datacenter, core.Command(), os.Getpid())

return &stdoutWriter{
prefix: prefix,
Expand Down Expand Up @@ -269,7 +270,7 @@ func (w *stdoutWriter) logAtLevel(level syslog.Priority, msg string, a ...interf
w.clk.Now().UTC().Format("2006-01-02T15:04:05.000000+00:00Z"),
w.prefix,
int(level),
path.Base(os.Args[0]),
core.Command(),
checkSummed(msg),
reset); err != nil {
panic(fmt.Sprintf("failed to write to stdout: %v\n", err))
Expand Down