Help us shape the future of Go! Take the 2026 Go Developer Survey

logs

package
v1.65.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 21, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CleanCmd = &cobra.Command{
	Use:     "clean",
	Short:   "Delete session logs",
	Long:    `Deletes captured session log files. Reports how many were removed.`,
	Example: `  eng logs clean`,
	RunE: func(cmd *cobra.Command, _args []string) error {
		entries, err := runlog.List()
		if err != nil {
			return err
		}
		if len(entries) == 0 {
			log.Info("No session logs to clean.")
			return nil
		}
		removed := 0
		for _, e := range entries {
			if err := os.Remove(e.Path); err != nil {
				log.Warn("Could not remove %s: %v", e.Name, err)
				continue
			}
			removed++
		}
		log.Success("Removed %d session log(s).", removed)
		return nil
	},
}

CleanCmd deletes session log files.

View Source
var ListCmd = &cobra.Command{
	Use:     "list",
	Aliases: []string{"ls"},
	Short:   "List recent session logs",
	Long:    `Lists captured session logs, newest first, with command, time, and size.`,
	Example: `  eng logs list`,
	Run: func(cmd *cobra.Command, _args []string) {
		listLogs()
	},
}

ListCmd lists recent session log files.

View Source
var LogsCmd = &cobra.Command{
	Use:   "logs",
	Short: "View session logs from verbose commands",
	Long: `Verbose commands (git bulk syncs, system updates) write full detail logs
to a file while the terminal shows only a clean summary.

Use these subcommands to inspect past runs without re-running them.`,
	Example: `  eng logs              # List recent session logs
  eng logs show         # Show the latest session log
  eng logs show git-sync-all --tail 50
  eng logs clean        # Delete all session logs`,
	Run: func(cmd *cobra.Command, _args []string) {
		listLogs()
	},
}

LogsCmd groups session-log inspection commands.

View Source
var ShowCmd = &cobra.Command{
	Use:   "show [name]",
	Short: "Show a session log (latest by default)",
	Long: `Prints a captured session log. With no name, shows the latest run.
Names accept exact matches or unique prefixes (see 'eng logs list').

Use --tail N to show only the last N lines, or --follow to stream new
lines like 'tail -f' until interrupted.`,
	Example: `  eng logs show
  eng logs show git-sync-all
  eng logs show --tail 50
  eng logs show system-update -f`,
	RunE: func(cmd *cobra.Command, args []string) error {
		name := ""
		if len(args) > 0 {
			name = args[0]
		}
		entry, err := runlog.Resolve(name)
		if err != nil {
			return err
		}
		if showFollow {
			return followLog(cmd, entry.Path)
		}
		return printLog(entry.Path, showTail)
	},
	ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
		if len(args) > 0 {
			return nil, cobra.ShellCompDirectiveNoFileComp
		}
		entries, err := runlog.List()
		if err != nil {
			return nil, cobra.ShellCompDirectiveNoFileComp
		}
		names := make([]string, len(entries))
		for i, e := range entries {
			names[i] = e.Name
		}
		return cmdutil.CompletePrefix(names, toComplete)
	},
}

ShowCmd prints a session log file.

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL