Skip to content

Commit

Permalink
Standardize path for debug logging to homedir
Browse files Browse the repository at this point in the history
This PR sets the path of the debug log to ~/.config/srepd/debug.log, to
keep it in a consistent location, no matter where srepd is envoked from.

Signed-off-by: Chris Collins <[email protected]>
  • Loading branch information
clcollins committed Mar 4, 2024
1 parent e1153be commit 6e4a564
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ but rather a simple tool to make on-call tasks easier.`,
bindArgsToViper(cmd)
},
Run: func(cmd *cobra.Command, args []string) {
f, err := tea.LogToFile("debug.log", "debug")
home, err := os.UserHomeDir()
cobra.CheckErr(err)
f, err := tea.LogToFile(home+"/.config/srepd/debug.log", "debug")
if err != nil {
fmt.Println("fatal:", err)
os.Exit(1)
Expand Down Expand Up @@ -115,7 +117,7 @@ func init() {
)

cobra.OnInitialize(initConfig)
rootCmd.Flags().BoolP("debug", "d", false, "Enable debugging output")
rootCmd.Flags().BoolP("debug", "d", false, "Enable debug logging (~/.config/srepd/debug.log)")
rootCmd.Flags().StringP("editor", "e", defaultEditor, "Editor to use for notes; $EDITOR takes precedence")
rootCmd.Flags().StringP("terminal", "t", defaultTerminal, "Terminal to use for exec commands")
rootCmd.Flags().StringP("shell", "s", defaultShell, "Shell to use for exec commands; $SHELL takes precedence")
Expand Down

0 comments on commit 6e4a564

Please sign in to comment.