Skip to content

Commit

Permalink
implement stream reading
Browse files Browse the repository at this point in the history
  • Loading branch information
solnicki committed Nov 8, 2024
1 parent 487c905 commit 86d7d35
Show file tree
Hide file tree
Showing 31 changed files with 444 additions and 983 deletions.
45 changes: 45 additions & 0 deletions cmd/logveil/logveil.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package logveil

import (
"bufio"
"log/slog"

"github.com/logmanager-oss/logveil/internal/anonymizer"
"github.com/logmanager-oss/logveil/internal/flags"
"github.com/logmanager-oss/logveil/internal/loader"
"github.com/logmanager-oss/logveil/internal/runner"
)

func Run() {
slog.Info("Anonymization process started...")

anonymizingDataDir, input, output, isLmExport := flags.Load()
defer input.Close()
defer output.Close()

anonymizingData, err := loader.Load(anonymizingDataDir)
if err != nil {
slog.Error("loading anonymizing data from dir %s: %v", anonymizingDataDir, err)
return
}
anonymizer := anonymizer.New(anonymizingData)

outputWriter := bufio.NewWriter(output)
defer outputWriter.Flush()

if isLmExport {
err := runner.AnonymizeLmExport(input, outputWriter, anonymizer)
if err != nil {
slog.Error("reading lm export input file %s: %v", input.Name(), err)
return
}
} else {
err := runner.AnonymizeLmBackup(input, outputWriter, anonymizer)
if err != nil {
slog.Error("reading lm backup input file %s: %v", input.Name(), err)
return
}
}

slog.Info("All done. Exiting...")
}
4 changes: 2 additions & 2 deletions cmd/main.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package main

import "github.com/logmanager-oss/logveil/internal/anonymizer"
import "github.com/logmanager-oss/logveil/cmd/logveil"

func main() {
anonymizer.Run()
logveil.Run()
}
Binary file added examples/.DS_Store
Binary file not shown.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 86d7d35

Please sign in to comment.