@@ -31,24 +31,15 @@ const (
3131// applied separately to stdout and stderr.
3232const defaultOutLimit datasize.ByteSize = 1 * datasize .KB
3333
34- // loggerProcess abstracts a logger process for a particular severity.
35- type loggerProcess interface {
36- // write writes the message to the logger.
37- write (tag , msg string ) (err error )
38-
39- // close closes the process's pipes and waits for the command to exit.
40- close () (err error )
41- }
42-
4334// systemLogger is the implementation of the [SystemLogger] interface for macOS,
4435// which uses the /usr/bin/logger command.
4536//
4637// TODO(e.burkov): Get rid of it when golang/go#59229 is resolved.
4738type systemLogger struct {
48- debug loggerProcess
49- info loggerProcess
50- warning loggerProcess
51- error loggerProcess
39+ debug * osProcess
40+ info * osProcess
41+ warning * osProcess
42+ error * osProcess
5243
5344 // tag is the prefix for all log messages.
5445 //
@@ -145,7 +136,7 @@ func (l *systemLogger) Close() (err error) {
145136 defer func () { err = errors .Annotate (err , "closing logger processes: %w" ) }()
146137
147138 var errs []error
148- procs := []loggerProcess {
139+ procs := []* osProcess {
149140 l .debug ,
150141 l .info ,
151142 l .warning ,
@@ -167,8 +158,8 @@ func (l *systemLogger) Close() (err error) {
167158 return errors .Join (errs ... )
168159}
169160
170- // process is an instance of the logger process with a particular severity.
171- type process struct {
161+ // osProcess is an instance of the logger process with a particular severity.
162+ type osProcess struct {
172163 // mu synchronizes writes to stdin between each other and with the process
173164 // closing.
174165 mu * sync.Mutex
@@ -195,7 +186,7 @@ func newProcess(
195186 ctx context.Context ,
196187 cmdCons executil.CommandConstructor ,
197188 sev severity ,
198- ) (p * process , err error ) {
189+ ) (p * osProcess , err error ) {
199190 const (
200191 binPath = "/usr/bin/logger"
201192 optionPriority = "-p"
@@ -228,7 +219,7 @@ func newProcess(
228219 return nil , fmt .Errorf ("starting command: %w" , err )
229220 }
230221
231- return & process {
222+ return & osProcess {
232223 mu : & sync.Mutex {},
233224 cmd : cmd ,
234225 stdin : stdinWriter ,
@@ -238,11 +229,8 @@ func newProcess(
238229 }, nil
239230}
240231
241- // type check
242- var _ loggerProcess = (* process )(nil )
243-
244- // write implements the [loggerProcess] interface for *process.
245- func (p * process ) write (tag , msg string ) (err error ) {
232+ // write writes the message to the logger.
233+ func (p * osProcess ) write (tag , msg string ) (err error ) {
246234 defer func () { err = errors .Annotate (err , "writing %s message" , p .severity ) }()
247235
248236 msg = strings .TrimSuffix (msg , "\n " )
@@ -255,8 +243,8 @@ func (p *process) write(tag, msg string) (err error) {
255243 return err
256244}
257245
258- // close implements the [loggerProcess] interface for *process .
259- func (p * process ) close () (err error ) {
246+ // close closes the process's pipes and waits for the command to exit .
247+ func (p * osProcess ) close () (err error ) {
260248 defer func () { err = errors .Annotate (err , "closing %s logger: %w" , p .severity ) }()
261249
262250 var errs []error
0 commit comments