MCPcopy Create free account
hub / github.com/DNAProject/DNA / FileOpen

Function FileOpen

common/log/log.go:317–337  ·  view source on GitHub ↗
(path string)

Source from the content-addressed store, hash-verified

315}
316
317func FileOpen(path string) (*os.File, error) {
318 if fi, err := os.Stat(path); err == nil {
319 if !fi.IsDir() {
320 return nil, fmt.Errorf("open %s: not a directory", path)
321 }
322 } else if os.IsNotExist(err) {
323 if err := os.MkdirAll(path, 0766); err != nil {
324 return nil, err
325 }
326 } else {
327 return nil, err
328 }
329
330 var currenttime = time.Now().Format("2006-01-02_15.04.05")
331
332 logfile, err := os.OpenFile(path+currenttime+"_LOG.log", os.O_RDWR|os.O_CREATE, 0666)
333 if err != nil {
334 return nil, err
335 }
336 return logfile, nil
337}
338
339//Init deprecated, use InitLog instead
340func Init(a ...interface{}) {

Callers 1

InitLogFunction · 0.85

Calls 1

ErrorfMethod · 0.80

Tested by

no test coverage detected