Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type LogStorage ¶
type LogStorage struct {
// contains filtered or unexported fields
}
LogStorage provides filesystem-based storage for Docker container logs.
func NewLogStorage ¶
func NewLogStorage(root string) *LogStorage
NewLogStorage creates a new LogStorage instance that stores log files in the specified root directory.
You can call LoadExistingMappings() after creation to rebuild the name->ID mapping from old containers.
func (*LogStorage) Create ¶
func (ls *LogStorage) Create(container log.Container) (io.WriteCloser, error)
Create creates a new log file for the specified container and returns an io.WriteCloser for writing log data.
It creates a container-specific directory at "[logDir]/[containerID]/" if it does not exist already, writes container metadata to "metadata.json", and creates a log file "[containerID]-json.log".
func (*LogStorage) LoadExistingMappings ¶
func (ls *LogStorage) LoadExistingMappings() error
LoadExistingMappings scans the logs root directory for existing container logs and rebuilds the in-memory name→ID mapping from metadata files.
This should be called during initialization to restore the mapping after a restart.
func (*LogStorage) Open ¶
func (ls *LogStorage) Open(containerNameOrID string) (io.ReadCloser, error)
Open opens the log file for the specified container and returns an io.ReadCloser for reading log data. The containerNameOrID parameter accepts either a container name or ID.
Returns log.Error with code log.ErrorCodeContainerNotFound if the container cannot be found.