Skip to content

Commit

Permalink
Remove unused logger formats
Browse files Browse the repository at this point in the history
Bug: b/356400943
Test: Existing tests
Change-Id: I1c948084f49d9388c85c561123eed43dde9f6c95
GitOrigin-RevId: d4164be4d20ee244678fe6b3db02f8f01771ee1c
  • Loading branch information
banikharbanda authored and copybara-github committed Aug 7, 2024
1 parent 77e0cd7 commit 752f999
Showing 1 changed file with 2 additions and 23 deletions.
25 changes: 2 additions & 23 deletions internal/pkg/logger/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,6 @@ const (
// TextFormat means records marshalled as proto-ASCII.
TextFormat Format = iota

// JSONFormat means records marshalled as JSON.
JSONFormat

// BinaryFormat means records marshalled as binary delimited by record size.
BinaryFormat

// ReducedTextFormat means records are marshalled as proto-ASCII without the
// command inputs and args.
ReducedTextFormat
Expand Down Expand Up @@ -263,10 +257,6 @@ func (f Format) String() string {
switch f {
case TextFormat:
return "text"
case JSONFormat:
return "json"
case BinaryFormat:
return "binary"
case ReducedTextFormat:
return "reducedtext"
default:
Expand All @@ -279,10 +269,6 @@ func ParseFormat(fs string) (Format, error) {
switch fs {
case "text":
return TextFormat, nil
case "json":
return JSONFormat, nil
case "binary":
return BinaryFormat, nil
case "reducedtext":
return ReducedTextFormat, nil
default:
Expand Down Expand Up @@ -312,7 +298,7 @@ func NewFromFormatFile(formatfile string, s stats.StatCollector, mi *ignoremisma
return nil, err
}
if format != TextFormat && format != ReducedTextFormat {
return nil, fmt.Errorf("only text:// or reducedtext:// formats are currently supported, received %v", formatfile)
return nil, fmt.Errorf("only text:// or reducedtext:// formats are supported, received %v", formatfile)
}
f, err := os.Create(filepath)
if err != nil {
Expand All @@ -328,10 +314,6 @@ func logFileSuffix(format Format) string {
return "rpl"
case ReducedTextFormat:
return "rrpl"
case JSONFormat:
return "rpljs"
case BinaryFormat:
return "rplpb"
default:
return ""
}
Expand Down Expand Up @@ -387,7 +369,7 @@ func (l *Logger) startBackgroundProcess() {
// New instantiates a new Logger.
func New(format Format, dir string, s stats.StatCollector, mi *ignoremismatch.MismatchIgnorer, e monitoring.StatExporter, u *usage.PsutilSampler, bqSpec *bigquery.BQSpec) (*Logger, error) {
if format != TextFormat && format != ReducedTextFormat {
return nil, fmt.Errorf("only text:// or reducedtext:// formats are currently supported, received %v", format)
return nil, fmt.Errorf("only text:// or reducedtext:// formats are supported, received %v", format)
}
ts := time.Now().Format("2006-01-02_15_04_05")
filename := filepath.Join(dir, fmt.Sprintf("reproxy_%s.%s", ts, logFileSuffix(format)))
Expand Down Expand Up @@ -761,8 +743,6 @@ func CommandRemoteMetadataFromProto(rPb *lpb.RemoteMetadata) *command.Metadata {
}

func toBytes(format Format, rec *lpb.LogRecord) ([]byte, error) {
// This only supports TextFormat for now.
// TODO(b/279056853): support other formats.
if format != TextFormat && format != ReducedTextFormat {
return nil, fmt.Errorf("only text or reducedtext formats are currently supported, received %s", format)
}
Expand Down Expand Up @@ -820,7 +800,6 @@ func ParseFromFormatFile(formatfile string) ([]*lpb.LogRecord, error) {

// ParseFromFile reads Records from a log file created by a Logger.
func ParseFromFile(format Format, filepath string) ([]*lpb.LogRecord, error) {
// TODO(b/279056853): support other formats.
if format != TextFormat && format != ReducedTextFormat {
return nil, fmt.Errorf("only text or reducedtext formats are currently supported, received %s", format)
}
Expand Down

0 comments on commit 752f999

Please sign in to comment.