Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Backports:SLE-15-SP4:FactoryCandidates
fstail
fstail-0.1.0.obscpio
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File fstail-0.1.0.obscpio of Package fstail
07070100000000000081A4000000000000000000000001641C1238000005C0000000000000000000000000000000000000001800000000fstail-0.1.0/.DEREK.ymlcurators: - alexellis - Shikachuu - welteki - nitishkumar71 - Jasstkn features: - dco_check - comments - pr_description_required - release_notes custom_messages: - name: template value: | This project uses Issue and PR templates and requires that all users fill out the template in detail before help can be given. To continue please edit your Issue/PR or open a new one, and please provide all the fields requested. Thank you for your contribution. - name: propose value: | This project follows a contributing guide which states that all changes must be proposed with an Issue before being worked on. Please raise an Issue and update your Pull Request to include the ID or link as part of the description. Thank you for your contribution. - name: test value: | This project follows a contributing guide which requires that all changes are tested before being merged. You should include worked examples that a maintainer can run to prove that the changes are good. Screenshots and command line output are also accepted, but must show the positive, and negative cases, not just that what was added worked as you expected. Thank you for your contribution. contributing_url: https://github.com/alexellis/arkade/blob/master/CONTRIBUTING.md 07070100000001000081A4000000000000000000000001641C12380000042B000000000000000000000000000000000000001500000000fstail-0.1.0/LICENSEMIT License Copyright (c) 2023 Alex Ellis Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 07070100000002000081A4000000000000000000000001641C123800000274000000000000000000000000000000000000001600000000fstail-0.1.0/MakefileLDFLAGS := "-s -w" export GO111MODULE=on .PHONY: dist dist: mkdir -p bin CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags $(LDFLAGS) -o bin/fstail CGO_ENABLED=0 GOOS=darwin go build -ldflags $(LDFLAGS) -o bin/fstail-darwin CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -a -ldflags $(LDFLAGS) -installsuffix cgo -o bin/fstail-darwin-arm64 CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -ldflags $(LDFLAGS) -o bin/fstail-arm64 CGO_ENABLED=0 GOOS=linux GOARCH=arm GOVER=7 go build -ldflags $(LDFLAGS) -o bin/fstail-armhf CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -ldflags $(LDFLAGS) -o bin/fstail.exe 07070100000003000081A4000000000000000000000001641C12380000091E000000000000000000000000000000000000001700000000fstail-0.1.0/README.md## fstail - scan a directory for changed files and tail them **What's this for?** When you need to see the output from all changed files within a directory. **Why doesn't `tail -f /var/logs/*` work?** Unfortunately, `tail -f /logs/*` may not do what you want it to do. Bash will expand `*` to all existing files within `/logs/` and then show the extra lines added to each of them. It also will not recurse down, any levels deeper than the current directory. **How is fstail different then?** `fstail` uses the [gopkg.in/fsnotify](https://pkg.go.dev/gopkg.in/fsnotify.v1@v1.4.7) to detect both new files, and existing files that are changed. It then starts concatenting their contents to the terminal. I needed this for [actuated.dev](https://actuated.dev) which launches microVMs on servers for CI. Each VM launched will create a different file at: `/var/log/actuated/GUID.txt`, and `tail -f *` would only find existing files. ### Usage Tail the current directory: ``` cd /var/log/actuated fstail [7cd0d139b24d9cd30e3ad9ce7afcfe5999d2bf20.txt] [ 12.770522] bash[1191]: 2023-03-22 11:04:00Z: Running job: arkade-e2e (run-job) [49c8f4be774730ff6e5070166fc34ac25dc0e320.txt] [ 13.363398] bash[1183]: 2023-03-22 11:04:00Z: Running job: arkade-e2e (k3sup) ``` To turn off the file prefix, set `FS_PREFIX=0`. ``` [ 12.770522] bash[1191]: 2023-03-22 11:04:00Z: Running job: arkade-e2e (run-job) [ 13.363398] bash[1183]: 2023-03-22 11:04:00Z: Running job: arkade-e2e (k3sup) ``` Tail files in a given directory: ``` fstail /var/log/nginx/ ``` By default, the base filename is going to be printed as a prefix for each tailed file: ```bash 1e51959055fb132720d03584388b5ac738689798.txt | Booting Linux Kernel.. OK 13d461e989733fa0f75df5227debab4be3504726.txt | Shutting down in 30s... ``` To suppress the prefix, run the command with `FS_PREFIX=0`. ### Installation Download a release binary: * [fstail releases](https://github.com/alexellis/fstail/releases/) Or install via Go to install from source: ```bash go install github.com/alexellis/fstail ``` If you need Go on a Linux system: ``` curl -sLS https://get.arkade.dev | sudo sh sudo arkade system install go ``` If you wish to build multi-arch binaries on your own machine: ```bash make dist ``` ## License Copyright Alex Ellis 2023 MIT license. 07070100000004000081A4000000000000000000000001641C12380000007E000000000000000000000000000000000000001400000000fstail-0.1.0/go.modmodule github.com/alexellis/fstail go 1.19 require gopkg.in/fsnotify.v1 v1.4.7 require golang.org/x/sys v0.6.0 // indirect 07070100000005000081A4000000000000000000000001641C123800000136000000000000000000000000000000000000001400000000fstail-0.1.0/go.sumgolang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= 07070100000006000081A4000000000000000000000001641C1238000007EF000000000000000000000000000000000000001500000000fstail-0.1.0/main.gopackage main import ( "bufio" "fmt" "io" "log" "os" "os/signal" "path" "syscall" "time" fsnotify "gopkg.in/fsnotify.v1" ) func main() { if len(os.Args) == 2 { if os.Args[1] == "-h" || os.Args[1] == "--help" { fmt.Printf(`fstail - Copyright Alex Ellis 2023 Usage: fstail fstail /var/log/actuated FS_PREFIX=0 fstail `) return } } var wd string if len(os.Args) > 1 { wd = os.Args[1] } else { cwd, err := os.Getwd() if err != nil { log.Fatal(err) } wd = cwd } printers := map[string]*Streamer{} watcher, err := fsnotify.NewWatcher() if err != nil { log.Fatal(err) } defer watcher.Close() done := make(chan bool) go func() { for { select { case event := <-watcher.Events: if event.Op&fsnotify.Write == fsnotify.Write { if _, ok := printers[event.Name]; !ok { log.Printf("Found: %s", path.Base(event.Name)) if f, err := os.Open(event.Name); err == nil { s := NewStreamer(f) go s.Stream() printers[event.Name] = s } else { log.Println(err) } } } case err := <-watcher.Errors: if err != nil { log.Fatalln("Error:", err) } } } }() err = watcher.Add(wd) if err != nil { log.Fatal(err) } sigs := make(chan os.Signal, 2) signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM) go func() { <-sigs for _, s := range printers { s.Close() } done <- true }() <-done } type Streamer struct { f *os.File } func NewStreamer(f *os.File) *Streamer { return &Streamer{f: f} } func (s *Streamer) Stream() { base := path.Base(s.f.Name()) prefix := fmt.Sprintf("%s| ", base) if v, ok := os.LookupEnv("FS_PREFIX"); ok && v == "0" { prefix = "" } reader := bufio.NewReader(s.f) for { line, err := reader.ReadString('\n') if err != nil { if err == io.EOF { time.Sleep(100 * time.Millisecond) continue } break } fmt.Printf("%s%s", prefix, string(line)) } } func (s *Streamer) Close() { if s.f != nil { s.f.Close() } } 07070100000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000B00000000TRAILER!!!18 blocks
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor