-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
solnicki
committed
Nov 18, 2024
1 parent
487c905
commit 28c5c53
Showing
33 changed files
with
528 additions
and
1,015 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package logveil | ||
|
||
import ( | ||
"bufio" | ||
"log/slog" | ||
"os" | ||
|
||
"github.com/logmanager-oss/logveil/internal/anonymizer" | ||
"github.com/logmanager-oss/logveil/internal/config" | ||
"github.com/logmanager-oss/logveil/internal/loader" | ||
"github.com/logmanager-oss/logveil/internal/runner" | ||
) | ||
|
||
func Run() { | ||
slog.Info("Anonymization process started...") | ||
|
||
config := &config.Config{} | ||
config.LoadAndValidate() | ||
|
||
if *config.IsVerbose { | ||
slog.SetLogLoggerLevel(slog.LevelDebug) | ||
} | ||
|
||
inputReader, err := os.Open(config.InputPath) | ||
if err != nil { | ||
return | ||
} | ||
defer inputReader.Close() | ||
|
||
var outputFile *os.File | ||
if config.OutputPath != "" { | ||
outputFile, err := os.Create(config.OutputPath) | ||
if err != nil { | ||
return | ||
} | ||
defer outputFile.Close() | ||
} else { | ||
outputFile = os.Stdout | ||
} | ||
|
||
outputWriter := bufio.NewWriter(outputFile) | ||
defer outputWriter.Flush() | ||
|
||
anonymizingData, err := loader.Load(config.AnonymizationDataPath) | ||
if err != nil { | ||
slog.Error("loading anonymizing data from dir %s: %v", config.AnonymizationDataPath, err) | ||
return | ||
} | ||
anonymizer := anonymizer.New(anonymizingData) | ||
|
||
if *config.IsLmExport { | ||
err := runner.AnonymizeLmExport(inputReader, outputWriter, anonymizer) | ||
if err != nil { | ||
slog.Error("reading lm export input file %s: %v", inputReader.Name(), err) | ||
return | ||
} | ||
} else { | ||
err := runner.AnonymizeLmBackup(inputReader, outputWriter, anonymizer) | ||
if err != nil { | ||
slog.Error("reading lm backup input file %s: %v", inputReader.Name(), err) | ||
return | ||
} | ||
} | ||
|
||
slog.Info("All done. Exiting...") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 not shown.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.