| 1 |
package logging_test |
| 2 |
|
| 3 |
import ( |
| 4 |
"time" |
| 5 |
|
| 6 |
"github.com/kisom/goutils/logging" |
| 7 |
) |
| 8 |
|
| 9 |
var log = logging.NewConsole() |
| 10 |
var olog = logging.NewConsole() |
| 11 |
|
| 12 |
func Example() { |
| 13 |
log.Info("example", "Hello, world.", nil) |
| 14 |
log.Warn("example", "this program is about to end", nil) |
| 15 |
|
| 16 |
log.Critical("example", "screaming into the void", nil) |
| 17 |
olog.Critical("other", "can anyone hear me?", nil) |
| 18 |
|
| 19 |
log.Warn("example", "but not for long", nil) |
| 20 |
|
| 21 |
log.Info("example", "fare thee well", nil) |
| 22 |
olog.Info("example", "all good journeys must come to an end", |
| 23 |
map[string]string{"when": time.Now().String()}) |
| 24 |
} |
| 25 |
|
| 26 |
func ExampleNewFromFile() { |
| 27 |
flog, err := logging.NewSplitFile("example.log", "example.err", true) |
| 28 |
if err != nil { |
| 29 |
log.Fatal("filelog", "failed to open logger", |
| 30 |
map[string]string{"error": err.Error()}) |
| 31 |
} |
| 32 |
|
| 33 |
flog.Info("filelog", "hello, world", nil) |
| 34 |
flog.Info("filelog", "some more things happening", nil) |
| 35 |
flog.Warn("filelog", "something suspicious has happened", nil) |
| 36 |
flog.Critical("filelog", "pick up that can, Citizen!", nil) |
| 37 |
} |