MCPcopy Index your code
hub / github.com/linuxkit/linuxkit / NewLogFile

Function NewLogFile

pkg/logwrite/logwrite.go:46–62  ·  view source on GitHub ↗

NewLogFile creates a new LogFile.

(dir, name string)

Source from the content-addressed store, hash-verified

44
45// NewLogFile creates a new LogFile.
46func NewLogFile(dir, name string) (*LogFile, error) {
47 // If the log exists already we want to append to it.
48 p := filepath.Join(dir, name+".log")
49 f, err := os.OpenFile(p, os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0644)
50 if err != nil {
51 return nil, err
52 }
53 fi, err := f.Stat()
54 if err != nil {
55 return nil, err
56 }
57 return &LogFile{
58 File: f,
59 Path: p,
60 BytesWritten: int(fi.Size()),
61 }, nil
62}
63
64// Write appends a message to the log file
65func (l *LogFile) Write(m *LogMessage) error {

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected