Skip to content

Commit

Permalink
Merge pull request #70 from babarot/babarot/log
Browse files Browse the repository at this point in the history
Revise log system
  • Loading branch information
babarot authored Feb 16, 2025
2 parents a05ccd9 + 613ef88 commit 4c86c51
Show file tree
Hide file tree
Showing 19 changed files with 501 additions and 80 deletions.
7 changes: 1 addition & 6 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,8 @@ scoops:
- repository:
owner: babarot
name: scoop-bucket
branch: main
token: "{{ .Env.SCOOP_GITHUB_TOKEN }}"
homepage: https://gomi.dev/
description: "🗑️ Your UNIX rm command with a safety net!"
description: A Safer Alternative to the UNIX rm Command!
license: MIT
url_template: "https://github.com/babarot/gomi/releases/download/{{ .Tag }}/{{ .ArtifactName }}"
commit_author:
name: github-actions
email: [email protected]
commit_msg_template: "Scoop update for {{ .ProjectName }} version {{ .Tag }}"
2 changes: 1 addition & 1 deletion .tagpr
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@
minorLabels = release/minor
releaseBranch = main
vPrefix = true
versionFile = VERSION
versionFile = VERSION,README.md
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ github:
repo: gomi
release:
name: gomi
tag: v1.2.3
tag: v1.4.0
command:
link:
- from: gomi
Expand Down
12 changes: 6 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ require (
al.essio.dev/pkg/shellescape v1.5.1
github.com/alecthomas/chroma v0.10.0
github.com/charmbracelet/bubbles v0.20.0
github.com/charmbracelet/bubbletea v1.2.4
github.com/charmbracelet/bubbletea v1.3.3
github.com/charmbracelet/lipgloss v1.0.0
github.com/charmbracelet/log v0.4.0
github.com/charmbracelet/x/ansi v0.7.0
github.com/charmbracelet/x/ansi v0.8.0
github.com/docker/go-units v0.5.0
github.com/dustin/go-humanize v1.0.1
github.com/fatih/color v1.18.0
github.com/gabriel-vasile/mimetype v1.4.8
github.com/go-playground/validator/v10 v10.24.0
github.com/go-playground/validator/v10 v10.25.0
github.com/gobwas/glob v0.2.3
github.com/google/uuid v1.6.0
github.com/jessevdk/go-flags v1.6.1
Expand All @@ -28,8 +28,8 @@ require (
github.com/nxadm/tail v1.4.11
github.com/otiai10/copy v1.14.1
github.com/rs/xid v1.6.0
github.com/samber/lo v1.47.0
golang.org/x/sync v0.10.0
github.com/samber/lo v1.49.1
golang.org/x/sync v0.11.0
gopkg.in/yaml.v2 v2.4.0
)

Expand All @@ -56,7 +56,7 @@ require (
golang.org/x/crypto v0.32.0 // indirect
golang.org/x/exp v0.0.0-20231006140011-7918f672742d // indirect
golang.org/x/net v0.34.0 // indirect
golang.org/x/sys v0.29.0 // indirect
golang.org/x/sys v0.30.0 // indirect
golang.org/x/text v0.21.0 // indirect
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
)
35 changes: 20 additions & 15 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ github.com/aymanbagabas/go-udiff v0.2.0 h1:TK0fH4MteXUDspT88n8CKzvK0X9O2xu9yQjWp
github.com/aymanbagabas/go-udiff v0.2.0/go.mod h1:RE4Ex0qsGkTAJoQdQQCA0uG+nAzJO/pI/QwceO5fgrA=
github.com/charmbracelet/bubbles v0.20.0 h1:jSZu6qD8cRQ6k9OMfR1WlM+ruM8fkPWkHvQWD9LIutE=
github.com/charmbracelet/bubbles v0.20.0/go.mod h1:39slydyswPy+uVOHZ5x/GjwVAFkCsV8IIVy+4MhzwwU=
github.com/charmbracelet/bubbletea v1.2.4 h1:KN8aCViA0eps9SCOThb2/XPIlea3ANJLUkv3KnQRNCE=
github.com/charmbracelet/bubbletea v1.2.4/go.mod h1:Qr6fVQw+wX7JkWWkVyXYk/ZUQ92a6XNekLXa3rR18MM=
github.com/charmbracelet/bubbletea v1.3.3 h1:WpU6fCY0J2vDWM3zfS3vIDi/ULq3SYphZhkAGGvmEUY=
github.com/charmbracelet/bubbletea v1.3.3/go.mod h1:dtcUCyCGEX3g9tosuYiut3MXgY/Jsv9nKVdibKKRRXo=
github.com/charmbracelet/lipgloss v1.0.0 h1:O7VkGDvqEdGi93X+DeqsQ7PKHDgtQfF8j8/O2qFMQNg=
github.com/charmbracelet/lipgloss v1.0.0/go.mod h1:U5fy9Z+C38obMs+T+tJqst9VGzlOYGj4ri9reL3qUlo=
github.com/charmbracelet/log v0.4.0 h1:G9bQAcx8rWA2T3pWvx7YtPTPwgqpk7D68BX21IRW8ZM=
github.com/charmbracelet/log v0.4.0/go.mod h1:63bXt/djrizTec0l11H20t8FDSvA4CRZJ1KH22MdptM=
github.com/charmbracelet/x/ansi v0.7.0 h1:/QfFmiXOGGwN6fRbzvQaYp7fu1pkxpZ3qFBZWBsP404=
github.com/charmbracelet/x/ansi v0.7.0/go.mod h1:KBUFw1la39nl0dLl10l5ORDAqGXaeurTQmwyyVKse/Q=
github.com/charmbracelet/x/ansi v0.8.0 h1:9GTq3xq9caJW8ZrBTe0LIe2fvfLR/bYXKTx2llXn7xE=
github.com/charmbracelet/x/ansi v0.8.0/go.mod h1:wdYl/ONOLHLIVmQaxbIYEC/cRKOQyjTkowiI4blgS9Q=
github.com/charmbracelet/x/exp/teatest v0.0.0-20231116172829-450eedbca1ab h1:+NUNHTfqUFw9qGNU4ApqomkRl76KHhCCRmLeW/1ULaU=
github.com/charmbracelet/x/exp/teatest v0.0.0-20231116172829-450eedbca1ab/go.mod h1:TckAxPtan3aJ5wbTgBkySpc50SZhXJRZ8PtYICnZJEw=
github.com/charmbracelet/x/term v0.2.1 h1:AQeHeLZ1OqSXhrAWpYUtZyX1T3zVxfpZuEQMIQaGIAQ=
Expand Down Expand Up @@ -47,8 +47,8 @@ github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/o
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
github.com/go-playground/validator/v10 v10.24.0 h1:KHQckvo8G6hlWnrPX4NJJ+aBfWNAE/HH+qdL2cBpCmg=
github.com/go-playground/validator/v10 v10.24.0/go.mod h1:GGzBIJMuE98Ic/kJsBXbz1x/7cByt++cQ+YOuDM5wus=
github.com/go-playground/validator/v10 v10.25.0 h1:5Dh7cjvzR7BRZadnsVOzPhWsrwUr0nmsZJxEAnFLNO8=
github.com/go-playground/validator/v10 v10.25.0/go.mod h1:GGzBIJMuE98Ic/kJsBXbz1x/7cByt++cQ+YOuDM5wus=
github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y=
github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8=
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 h1:El6M4kTTCOh6aBiKaUGG7oYTSPP8MxqL4YI3kZKwcP4=
Expand All @@ -63,6 +63,8 @@ github.com/k0kubun/pp/v3 v3.4.1 h1:1WdFZDRRqe8UsR61N/2RoOZ3ziTEqgTPVqKrHeb779Y=
github.com/k0kubun/pp/v3 v3.4.1/go.mod h1:+SiNiqKnBfw1Nkj82Lh5bIeKQOAkPy6Xw9CAZUZ8npI=
github.com/k1LoW/duration v1.2.0 h1:qq1gWtPh7YROFyerBufVP+ATR11mOOHDInrcC/Xe/6A=
github.com/k1LoW/duration v1.2.0/go.mod h1:qUa0NptIiUl5EUsCc8wIiSaHuNjS4wmpYNMHp0l6pos=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ=
Expand All @@ -89,6 +91,8 @@ github.com/muesli/reflow v0.3.0 h1:IFsN6K9NfGtjeggFP+68I4chLZV2yIKsXJFNZ+eWh6s=
github.com/muesli/reflow v0.3.0/go.mod h1:pbwTDkVPibjO2kyvBQRBxTWEEGDGq0FlB1BIKtnHY/8=
github.com/muesli/termenv v0.15.2 h1:GohcuySI0QmI3wN8Ok9PtKGkgkFIk7y6Vpb5PvrY+Wo=
github.com/muesli/termenv v0.15.2/go.mod h1:Epx+iuz8sNs7mNKhxzH4fWXGNpZwUaJKRS1noLXviQ8=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
github.com/nxadm/tail v1.4.11 h1:8feyoE3OzPrcshW5/MJ4sGESc5cqmGkGCWlco4l0bqY=
github.com/nxadm/tail v1.4.11/go.mod h1:OTaG3NK980DZzxbRq6lEuzgU+mug70nY11sMd4JXXHc=
github.com/otiai10/copy v1.14.1 h1:5/7E6qsUMBaH5AnQ0sSLzzTg1oTECmcCmT6lvF45Na8=
Expand All @@ -105,30 +109,31 @@ github.com/rs/xid v1.6.0 h1:fV591PaemRlL6JfRxGDEPl69wICngIQ3shQtzfy2gxU=
github.com/rs/xid v1.6.0/go.mod h1:7XoLgs4eV+QndskICGsho+ADou8ySMSjJKDIan90Nz0=
github.com/sahilm/fuzzy v0.1.1 h1:ceu5RHF8DGgoi+/dR5PsECjCDH1BE3Fnmpo7aVXOdRA=
github.com/sahilm/fuzzy v0.1.1/go.mod h1:VFvziUEIMCrT6A6tw2RFIXPXXmzXbOsSHF0DOI8ZK9Y=
github.com/samber/lo v1.47.0 h1:z7RynLwP5nbyRscyvcD043DWYoOcYRv3mV8lBeqOCLc=
github.com/samber/lo v1.47.0/go.mod h1:RmDH9Ct32Qy3gduHQuKJ3gW1fMHAnE/fAzQuf6He5cU=
github.com/samber/lo v1.49.1 h1:4BIFyVfuQSEpluc7Fua+j1NolZHiEHEpaSEKdsH0tew=
github.com/samber/lo v1.49.1/go.mod h1:dO6KHFzUKXgP8LDhU0oI8d2hekjXnGOu0DB8Jecxd6o=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
golang.org/x/crypto v0.32.0 h1:euUpcYgM8WcP71gNpTqQCn6rC2t6ULUPiOzfWaXVVfc=
golang.org/x/crypto v0.32.0/go.mod h1:ZnnJkOaASj8g0AjIduWNlq2NRxL0PlBrbKVyZ6V/Ugc=
golang.org/x/exp v0.0.0-20231006140011-7918f672742d h1:jtJma62tbqLibJ5sFQz8bKtEM8rJBtfilJ2qTU199MI=
golang.org/x/exp v0.0.0-20231006140011-7918f672742d/go.mod h1:ldy0pHrwJyGW56pPQzzkH36rKxoZW1tw7ZJpeKx+hdo=
golang.org/x/net v0.34.0 h1:Mb7Mrk043xzHgnRM88suvJFwzVrRfHEHJEl5/71CKw0=
golang.org/x/net v0.34.0/go.mod h1:di0qlW3YNM5oh6GqDGQr92MyTozJPmybPK4Ev/Gm31k=
golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ=
golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sync v0.11.0 h1:GGz8+XQP4FvTTrjZPzNKTMFtSXH80RAzG+5ghFPgK9w=
golang.org/x/sync v0.11.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.29.0 h1:TPYlXGxvx1MGTn2GiZDhnjPA9wZzZeGKHHmKhHYvgaU=
golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc=
golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo=
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU=
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
Expand Down
47 changes: 10 additions & 37 deletions internal/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,18 @@ package cli
import (
"errors"
"fmt"
"io"
"log/slog"
"os"
"path/filepath"
"strings"
"sync"
"time"

"github.com/babarot/gomi/internal/config"
"github.com/babarot/gomi/internal/env"
"github.com/babarot/gomi/internal/trash"
"github.com/babarot/gomi/internal/trash/legacy"
"github.com/babarot/gomi/internal/trash/xdg"
"github.com/babarot/gomi/internal/utils/debug"
"github.com/charmbracelet/log"
"github.com/babarot/gomi/internal/utils/env"
"github.com/babarot/gomi/internal/utils/log"
"github.com/jessevdk/go-flags"
"github.com/rs/xid"
)
Expand Down Expand Up @@ -72,38 +69,14 @@ func Run(v Version) error {
return err
}

logDir := filepath.Dir(env.GOMI_LOG_PATH)
if _, err := os.Stat(logDir); os.IsNotExist(err) {
err := os.MkdirAll(logDir, 0755)
if err != nil {
return err
}
}

var w io.Writer
if file, err := os.OpenFile(env.GOMI_LOG_PATH, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644); err == nil {
w = file
} else {
w = os.Stderr
}

logger := log.NewWithOptions(os.Stderr, log.Options{
ReportCaller: true,
ReportTimestamp: true,
TimeFormat: time.Kitchen,
Level: log.DebugLevel,
Formatter: func() log.Formatter {
// TODO: fix this
// json is no longer valid argument so doesnt work anymore.
if strings.ToLower(opt.Meta.Debug) == "json" {
return log.JSONFormatter
}
return log.TextFormatter
}(),
})
logger.SetOutput(w)
logger.With("run_id", runID())
slog.SetDefault(slog.New(logger))
_ = log.New(
log.UseLevel(log.DebugLevel),
log.UseOutputPath(env.GOMI_LOG_PATH),
log.UseTimeFormat(time.Kitchen),
log.UseReportTimestamp(true),
log.UseReportCaller(true),
log.AsDefault(), // seamlessly integrate with log/slog
)

defer slog.Debug("main function finished\n\n\n")
slog.Debug("main function started", "version", v.Version, "revision", v.Revision, "buildDate", v.BuildDate)
Expand Down
25 changes: 17 additions & 8 deletions internal/trash/filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,29 +32,38 @@ type FilterOptions struct {
// Filter applies filtering rules to a slice of items
func Filter[T Filterable](items []T, opts FilterOptions) []T {
slog.Debug("starting filter",
"initial_items", len(items),
"exclude_files", len(opts.Exclude.Files),
"exclude_patterns", len(opts.Exclude.Patterns))
"len(items)", len(items),
slog.Group("exclude",
"files", len(opts.Exclude.Files),
"patterns", len(opts.Exclude.Patterns),
"globs", len(opts.Exclude.Globs),
"size.max", opts.Exclude.Size.Max,
"size.min", opts.Exclude.Size.Min,
),
slog.Group("include",
"period", opts.Include.Period,
),
)

// Filter by filename exclusions
items = rejectByNames(items, opts.Exclude.Files)
slog.Debug("after name filtering", "remaining_items", len(items))
slog.Debug("after name filtering", "len(items)", len(items))

// Filter by patterns
items = rejectByPatterns(items, opts.Exclude.Patterns)
slog.Debug("after pattern filtering", "remaining_items", len(items))
slog.Debug("after pattern filtering", "len(items)", len(items))

// Filter by globs
items = rejectByGlobs(items, opts.Exclude.Globs)
slog.Debug("after glob filtering", "remaining_items", len(items))
slog.Debug("after glob filtering", "len(items)", len(items))

// Filter by size
items = rejectBySize(items, opts.Exclude.Size)
slog.Debug("after size filtering", "remaining_items", len(items))
slog.Debug("after size filtering", "len(items)", len(items))

// Filter by time period
items = filterByPeriod(items, opts.Include.Period)
slog.Debug("after period filtering", "remaining_items", len(items))
slog.Debug("after period filtering", "len(items)", len(items))

return items
}
Expand Down
1 change: 1 addition & 0 deletions internal/trash/legacy/history/history.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ func (h History) Filter() []File {
Include: h.config.Include,
Exclude: h.config.Exclude,
}
slog.Debug("legacy filter items", "len(files)", len(h.Files))
return trash.Filter(h.Files, opts)
}

Expand Down
3 changes: 2 additions & 1 deletion internal/trash/legacy/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/babarot/gomi/internal/fs"
"github.com/babarot/gomi/internal/trash"
"github.com/babarot/gomi/internal/trash/legacy/history"
"github.com/babarot/gomi/internal/utils/log"
"github.com/google/uuid"
)

Expand All @@ -31,7 +32,7 @@ type Storage struct {

// NewStorage creates a new legacy storage instance
func NewStorage(cfg trash.Config) (trash.Storage, error) {
slog.Info("initialize legacy storage")
slog.Info(log.UnderBold("initialize legacy storage"))

var root string
if cfg.GomiDir != "" {
Expand Down
6 changes: 4 additions & 2 deletions internal/trash/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (
"os"
"path/filepath"
"strings"

"github.com/babarot/gomi/internal/utils/log"
)

// Strategy represents the trash management strategy
Expand Down Expand Up @@ -73,7 +75,7 @@ func NewManager(cfg Config, opts ...ManagerOption) (*Manager, error) {
slog.Debug("determine strategy based on current storages")
m.strategy = determineStrategy(m.storages)
}
slog.Info("trash manager", "strategy", m.strategy)
slog.Info(log.Highlight("trash manager"), "strategy", m.strategy)

return m, nil
}
Expand Down Expand Up @@ -149,7 +151,7 @@ func (m *Manager) List() ([]*File, error) {
continue
}
allFiles = append(allFiles, files...)
slog.Debug("list files",
slog.Info("list files",
"storage_type",
storage.Info().Type,
"len(files)",
Expand Down
4 changes: 3 additions & 1 deletion internal/trash/xdg/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (

"github.com/babarot/gomi/internal/fs"
"github.com/babarot/gomi/internal/trash"
"github.com/babarot/gomi/internal/utils/log"
)

// Storage implements the trash.Storage interface for XDG trash specification
Expand Down Expand Up @@ -44,7 +45,7 @@ type trashLocation struct {

// NewStorage creates a new XDG-compliant trash storage
func NewStorage(cfg trash.Config) (trash.Storage, error) {
slog.Info("initialize xdg storage")
slog.Info(log.UnderBold("initialize xdg storage"))

s := &Storage{config: cfg}

Expand Down Expand Up @@ -368,5 +369,6 @@ func (s *Storage) filter(files []*trash.File) []*trash.File {
Include: s.config.History.Include,
Exclude: s.config.History.Exclude,
}
slog.Debug("xdg filter items", "len(files)", len(files))
return trash.Filter(files, opts)
}
3 changes: 2 additions & 1 deletion internal/ui/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ type inventoryLoadedMsg struct {

func (m Model) loadInventory() tea.Msg {
files := m.files
slog.Debug("loadInventory starts", "len(files)", len(files))
slog.Info("loadInventory starts", "len(files)", len(files))

if len(files) == 0 {
return errorMsg{errors.New("no deleted files found")}
}
Expand Down
2 changes: 1 addition & 1 deletion internal/utils/debug/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"io"
"os"

"github.com/babarot/gomi/internal/env"
"github.com/babarot/gomi/internal/utils/env"
"github.com/mattn/go-isatty"
"github.com/nxadm/tail"
)
Expand Down
File renamed without changes.
Loading

0 comments on commit 4c86c51

Please sign in to comment.