Created
January 3, 2017 08:34
-
-
Save simeji/846a1f19d3c85e0154544dc94b85180b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"log" | |
"os" | |
) | |
const ( | |
LogFileName string = "/tmp/go-debug.log" | |
) | |
func Debug(s interface{}, label string) { | |
f, err := os.OpenFile(LogFileName, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666) | |
if err != nil { | |
log.Fatalf("error opening file: %v", err) | |
} | |
defer f.Close() | |
log.SetOutput(f) | |
log.Println("%s : %v", label, s) | |
} | |
func DebugRune(s rune,label string) { | |
f, err := os.OpenFile(LogFileName, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666) | |
if err != nil { | |
log.Fatalf("error opening file: %v", err) | |
} | |
defer f.Close() | |
log.SetOutput(f) | |
log.Printf("%s : %#U", label, s) | |
} | |
func DebugRunes(s []rune,label string) { | |
f, err := os.OpenFile(LogFileName, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666) | |
if err != nil { | |
log.Fatalf("error opening file: %v", err) | |
} | |
defer f.Close() | |
log.SetOutput(f) | |
for i, ss := range s { | |
log.Printf("%s : %#U : %d", label, ss, i) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment