Compare commits

...

3 Commits

Author SHA1 Message Date
7d0620fe3e Fix system config file path 2025-03-09 01:55:11 -05:00
3115c5feef Actors are formatted better when logged 2025-03-09 01:54:53 -05:00
10ca4f4671 Add "named" actor interface 2025-02-05 16:49:27 -05:00
3 changed files with 14 additions and 2 deletions

View File

@ -29,6 +29,14 @@ type Actor interface {
Type() string
}
// Named is any object with a name.
type Named() string {
// Name returns the name. This doesn't need to be the same as Type. It
// must return the same string every time. It is used to differentiate
// actors of the same type in logs.
Name() string
}
// FlagAdder is any object that can add [Flag]s to a [FlagSet]. Actors which
// implement this interface will be called upon to add flags during and only
// during the flag parsing phase.

2
ini.go
View File

@ -162,7 +162,7 @@ func configFiles(program string) ([]string, error) {
userConfig, err := os.UserConfigDir()
if err != nil { return nil, err }
return []string {
filepath.Join("/etc", program),
filepath.Join("/etc", program, program + ".conf"),
filepath.Join(userConfig, program),
}, nil
}

View File

@ -77,7 +77,11 @@ func logActors (actors iter.Seq[Actor]) {
}
types := make(map[string] int)
for actor := range actors {
types[actor.Type()] += 1
typ := actor.Type()
if named, ok := actor.(Named); ok {
typ = fmt.Sprintf("%s/%s", typ, named.Name())
}
types[typ] += 1
}
for typ, count := range types {
if count > 1 {