Skip to content

Commit

Permalink
add test example and readme
Browse files Browse the repository at this point in the history
  • Loading branch information
adwpc committed Nov 4, 2020
1 parent e6b94df commit ccace91
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 1 deletion.
26 changes: 25 additions & 1 deletion README.md
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

15 changes: 15 additions & 0 deletions example/main.go
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!")
}
29 changes: 29 additions & 0 deletions log_test.go
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
}

0 comments on commit ccace91

Please sign in to comment.