file_position
File position tracking with rotation detection.
Classes¶
LogFilePosition ¶
Tracks file position and detects log rotation/truncation.
Handles common scenarios like log file rotation (inode change) and file truncation (size decrease).
Attributes:
| Name | Type | Description |
|---|---|---|
path |
Path to the file being tracked. |
Source code in snakesee/parser/file_position.py
Attributes¶
Functions¶
__init__ ¶
Initialize position tracker.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Path
|
Path to the file to track. |
required |
check_rotation ¶
Check if the file has been rotated or truncated.
Detects rotation by checking for inode change or file truncation (current size less than last known position).
Returns:
| Type | Description |
|---|---|
bool
|
True if the file was rotated and position was reset. |
Source code in snakesee/parser/file_position.py
clamp_to_size ¶
Clamp offset to file bounds.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_size
|
int
|
Current file size (must be non-negative). |
required |