Skip to content

Commit

Permalink
pkg: newlog: make a small improvement
Browse files Browse the repository at this point in the history
This commit makes a small improvement in newlogd.go:

- Agregate two ifs into one: getAppStatsMap() must be called only if
  appuuid is not null
- Remove redundant attribution: getAppStatsMap() already attributes the
  found item to the map ("appStatsMap[appuuid] = appM") inside the
  function

Signed-off-by: Renê de Souza Pinto <rene@renesp.com.br>
  • Loading branch information
rene committed Mar 15, 2023
1 parent ee2667d commit cc81d82
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions pkg/newlog/cmd/newlogd.go
Original file line number Diff line number Diff line change
Expand Up @@ -764,10 +764,6 @@ func writelogFile(logChan <-chan inputEntry, moveChan chan fileChanInfo) {

case entry := <-logChan:
appuuid := checkAppEntry(&entry)
var appM statsLogFile
if appuuid != "" {
appM = getAppStatsMap(appuuid)
}
timeS, _ := getPtypeTimestamp(entry.timestamp)
mapLog := logs.LogEntry{
Severity: entry.severity,
Expand All @@ -782,13 +778,11 @@ func writelogFile(logChan <-chan inputEntry, moveChan chan fileChanInfo) {
mapJentry, _ := json.Marshal(&mapLog)
logline := string(mapJentry) + "\n"
if appuuid != "" {
appM := getAppStatsMap(appuuid)
len := writelogEntry(&appM, logline)

logmetrics.AppMetrics.NumBytesWrite += uint64(len)
appStatsMap[appuuid] = appM

trigMoveToGzip(fileinfo, &appM, appuuid, moveChan, false)

} else {
len := writelogEntry(&devStats, logline)
updateDevInputlogStats(entry.source, uint64(len))
Expand Down

0 comments on commit cc81d82

Please sign in to comment.