-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
69 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,26 @@ | ||
# ion-log | ||
golang logger used by ion | ||
## QuickStart | ||
``` | ||
package main | ||
import ( | ||
log "github.com/pion/ion-log" | ||
) | ||
func init() { | ||
fixByFile := []string{"asm_amd64.s", "proc.go"} | ||
fixByFunc := []string{} | ||
log.Init("debug", fixByFile, fixByFunc) | ||
} | ||
func main() { | ||
log.Infof("Hello ION!") | ||
} | ||
``` | ||
## Feature | ||
* GoodFormat: [date time] [Level] [Line][File][Func] => YourLog | ||
``` | ||
[2020-11-04 16:13:54.593] [INFO] [14][main.go][main] => Hello ION! | ||
``` | ||
* FixByHand: you can fixByFile or fixByFunc when you found the log line not right | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package main | ||
|
||
import ( | ||
log "github.com/pion/ion-log" | ||
) | ||
|
||
func init() { | ||
fixByFile := []string{"asm_amd64.s", "proc.go"} | ||
fixByFunc := []string{} | ||
log.Init("debug", fixByFile, fixByFunc) | ||
} | ||
|
||
func main() { | ||
log.Infof("Hello ION!") | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package log | ||
|
||
import "testing" | ||
|
||
func TestLogFormat(t *testing.T) { | ||
fixByFile := []string{"asm_amd64.s", "proc.go"} | ||
fixByFunc := []string{} | ||
Init("debug", fixByFile, fixByFunc) | ||
Infof("Hello %s!", "ION") | ||
} | ||
|
||
func TestLogFixByFunc(t *testing.T) { | ||
fixByFile := []string{"asm_amd64.s", "proc.go"} | ||
fixByFunc := []string{"tRunner"} | ||
Init("debug", fixByFile, fixByFunc) | ||
Infof("Hello %s!", "ION") | ||
} | ||
|
||
func TestLogFixByFile(t *testing.T) { | ||
fixByFile := []string{"asm_amd64.s", "proc.go"} | ||
fixByFunc := []string{} | ||
Init("debug", fixByFile, fixByFunc) | ||
printOK := make(chan struct{}) | ||
go func() { | ||
Infof("Hello %s!", "ION") | ||
printOK <- struct{}{} | ||
}() | ||
<-printOK | ||
} |