MCPcopy
hub / github.com/dgraph-io/dgraph / rotate

Method rotate

x/log_writer.go:197–217  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

195}
196
197func (l *LogWriter) rotate() error {
198 if l == nil {
199 return nil
200 }
201
202 l.flush()
203 if err := l.file.Close(); err != nil {
204 return err
205 }
206
207 if _, err := os.Stat(l.FilePath); err == nil {
208 // move the existing file
209 newname := backupName(l.FilePath)
210 if err := os.Rename(l.FilePath, newname); err != nil {
211 return fmt.Errorf("can't rename log file: %s", err)
212 }
213 }
214
215 l.manageChannel <- true
216 return l.open()
217}
218
219func (l *LogWriter) open() error {
220 if l == nil {

Callers 1

WriteMethod · 0.95

Calls 6

flushMethod · 0.95
openMethod · 0.95
backupNameFunction · 0.70
CloseMethod · 0.65
RenameMethod · 0.65
ErrorfMethod · 0.45

Tested by

no test coverage detected