Categorygithub.com/MaxSchaefer/macos-log-stream
repositorypackage
0.0.0-20221124183856-194e68fd7a89
Repository: https://github.com/maxschaefer/macos-log-stream.git
Documentation: pkg.go.dev

# Packages

No description provided by the author

# README

macos-log-stream

Go wrapper around the > log stream command of the unified logging system on MacOS.

pkg/mls

This example shows the main purpose of the package. If you start gathering logs, the mls package runs log stream --color none --style ndjson. When logs.Predicate is set, the mls package appends ... --predicate [logs.Predicate] to the command.

package main

import (
	"fmt"
	"github.com/MaxSchaefer/macos-log-stream/pkg/mls"
)

func main() {
	logs := mls.NewLogs()

	// logs.Predicate = ""

	if err := logs.StartGathering(); err != nil {
		panic(err)
	}

	for log := range logs.Channel {
		fmt.Println(log.EventMessage)
	}
}

cli

To build the cli run make build.

# Show logs when the webcam turns on or off
mls -predicate 'subsystem == "com.apple.UVCFamily" && (eventMessage CONTAINS[c] "start stream" || eventMessage CONTAINS[c] "stop stream")'