Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this PR do
support symlink file detect and fix symlink file nil check
Rationale for this change
This pull request includes several enhancements and bug fixes in the
lib/reader/harvester/harvester.go
,lib/util/file.go
, andplugin/logs/file_detect.go
files. The changes focus on improving error handling, removing unused code, and adding new utility functions.Error handling improvements:
lib/reader/harvester/harvester.go
: Added checks to ensure the file is not nil before proceeding with operations in theNewHarvester
,NewJsonFileReader
, andNewLogFileReader
functions. [1] [2] [3] [4]Code cleanup:
lib/reader/harvester/harvester.go
: Removed the unusedNewPlainTextRead
function.New utility functions:
lib/util/file.go
: AddedCountFileRows
andResolveSymlink
functions to count the number of rows in a file and resolve the target file path of a symbolic link, respectively. [1] [2] [3]Integration of new utility functions:
plugin/logs/file_detect.go
: Integrated theResolveSymlink
function to handle symbolic links in thejudgeEvent
method. [1] [2]Standards checklist