Created
August 30, 2012 10:04
-
-
Save border/3525344 to your computer and use it in GitHub Desktop.
Revisions
-
border revised this gist
Aug 30, 2012 . 2 changed files with 24 additions and 18 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,15 +1,12 @@ package utils import ( "log" "os" ) var ( Log *log.Logger ) func NewLog(logpath string) { @@ -18,17 +15,5 @@ func NewLog(logpath string) { if err != nil { panic(err) } Log = log.New(file, "", log.LstdFlags|log.Lshortfile) } 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,21 @@ package main import ( "./utils" "flag" "time" ) var ( logpath = flag.String("logpath", "/tmp/weather.log", "Log Path") ) func main() { flag.Parse() utils.NewLog(*logpath) utils.Log.Println("hello") for i := 0; i < 10; i++ { utils.Log.Println(i) } time.Sleep(3 * time.Second) } -
border renamed this gist
Aug 30, 2012 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
border created this gist
Aug 30, 2012 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,34 @@ package main import ( "flag" "log" "os" "time" ) var ( lg *log.Logger logpath = flag.String("logpath", "/tmp/weather.log", "Log Path") ) func NewLog(logpath string) { println("LogFile: " + logpath) file, err := os.Create(logpath) if err != nil { panic(err) } lg = log.New(file, "", log.LstdFlags|log.Lshortfile) } func main() { flag.Parse() NewLog(*logpath) go func() { lg.Println("hello") for i := 0; i < 10; i++ { lg.Println(i) } }() time.Sleep(3 * time.Second) }