github.com/attic-labs/noms@v0.0.0-20210827224422-e5fa29d95e8b/samples/go/decent/lib/logger.go (about) 1 // See: https://github.com/attic-labs/noms/issues/3808 2 // +build ignore 3 4 // Copyright 2017 Attic Labs, Inc. All rights reserved. 5 // Licensed under the Apache License, version 2.0: 6 // http://www.apache.org/licenses/LICENSE-2.0 7 8 package lib 9 10 import ( 11 "fmt" 12 "log" 13 "os" 14 15 "github.com/attic-labs/noms/go/d" 16 "github.com/attic-labs/noms/samples/go/decent/dbg" 17 ) 18 19 func NewLogger(username string) *log.Logger { 20 f, err := os.OpenFile(dbg.Filepath, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0644) 21 d.PanicIfError(err) 22 prefix := fmt.Sprintf("%d-%s: ", os.Getpid(), username) 23 return log.New(f, prefix, 0644) 24 }