Skip to content

Commit

Permalink
set log output type
Browse files Browse the repository at this point in the history
  • Loading branch information
lucky-lee committed May 11, 2020
1 parent e1969e4 commit 2518dd2
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
16 changes: 16 additions & 0 deletions gLog/config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package gLog

const (
OUTPUT_STDOUT uint8 = 1
OUTPUT_FILE uint8 = 2
)

var outputType uint8 = OUTPUT_FILE

func SetOutputType(output uint8) {
outputType = output
}

func OutputType() uint8 {
return outputType
}
5 changes: 5 additions & 0 deletions gLog/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ func formatContent(desc string, format string, val interface{}) string {

//write content to log file
func toFile(name string, fileDir string, desc string, value interface{}) {
//out stdout
if OutputType() == OUTPUT_STDOUT {
Log(name, desc, value)
return
}
//create dir
gFile.DirAutoCreate(fileDir)

Expand Down

0 comments on commit 2518dd2

Please sign in to comment.