Skip to content

Commit

Permalink
Расширение детального лога
Browse files Browse the repository at this point in the history
  • Loading branch information
NuclearAPK committed Jan 12, 2021
1 parent e475082 commit 20e4872
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions conf/settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ patch_logfile: "D:\\tmp\\techLogData\\log\\"
log_level: 3
#
# Уровень параллелизма
maxdop: 1
maxdop: 5
#
# 0 - отключена сортировка файлов по размеру, 1 - сортировка по убыванию, 2 - сортировка по возрастанию
# полезно включать при массовых операциях, для равномерного распределения файлов по потокам
sorting: 0
sorting: 1
8 changes: 4 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ func getFilesPacked(arrFiles []*files, maxdop int) map[int][]files {

func readFile(file files) ([]byte, int64, error) {

var lastPosition int64
currPosition := file.LastPosition

openFile, err := os.Open(file.Path)
if err != nil {
Expand All @@ -258,15 +258,15 @@ func readFile(file files) ([]byte, int64, error) {

for {
n, err := openFile.Read(buffer)
lastPosition += int64(n)
currPosition += int64(n)
if err == io.EOF { // если конец файла
break // выходим из цикла
}
data = append(data, buffer[:n]...)
}

openFile.Close()
return data, lastPosition, nil
return data, currPosition, nil
}

// формирование наименование индекса по правилам, заданным в conf файле
Expand Down Expand Up @@ -495,7 +495,7 @@ func jobExtractTechLogs(filesInPackage []files, keyInPackage int, config *conf,
logr.WithFields(logr.Fields{
"object": "Data",
"title": "Succeful reading",
}).Infof("Package %d, file %s", keyInPackage, file.Path)
}).Infof("Package %d, file %s, start_position: %d, end position: %d", keyInPackage, file.Path, file.LastPosition, currentPosition)
}
// обходим события. Каждому событию соответстует bulk буффер
for keyM, buf := range mapEventsBuffer {
Expand Down

0 comments on commit 20e4872

Please # to comment.