mirror of
https://github.com/nxshock/logwriter.git
synced 2025-07-02 00:23:41 +05:00
Fix README example format
This commit is contained in:
parent
ba9d5318ac
commit
c44d147b9c
1 changed files with 20 additions and 20 deletions
40
README.md
40
README.md
|
@ -7,30 +7,30 @@ Provides time prefix generation for each line of provided messages.
|
||||||
## Usage example
|
## Usage example
|
||||||
|
|
||||||
```go
|
```go
|
||||||
import "github.com/nxshock/logwriter"
|
import "github.com/nxshock/logwriter"
|
||||||
|
|
||||||
// Create new writer that writes result to stdout
|
// Create new writer that writes result to stdout
|
||||||
writer := logwriter.New(os.Stdout)
|
writer := logwriter.New(os.Stdout)
|
||||||
|
|
||||||
// Set custom time format and timezone if needed
|
// Set custom time format and timezone if needed
|
||||||
writer.TimeFormat = "02.01.06 15:04:05"
|
writer.TimeFormat = "02.01.06 15:04:05"
|
||||||
writer.TimeZone = time.UTC
|
writer.TimeZone = time.UTC
|
||||||
|
|
||||||
writer.Print("hello world")
|
writer.Print("hello world")
|
||||||
// result:
|
// result:
|
||||||
// 02.01.06 15:04:05 hello world
|
// 02.01.06 15:04:05 hello world
|
||||||
|
|
||||||
writer.Write([]byte("line 1\nline 2\nline 3"))
|
writer.Write([]byte("line 1\nline 2\nline 3"))
|
||||||
// result:
|
// result:
|
||||||
// 02.01.06 15:04:05 line 1
|
// 02.01.06 15:04:05 line 1
|
||||||
// 02.01.06 15:04:05 line 2
|
// 02.01.06 15:04:05 line 2
|
||||||
// 02.01.06 15:04:05 line 3
|
// 02.01.06 15:04:05 line 3
|
||||||
|
|
||||||
writer.Print("hello ")
|
writer.Print("hello ")
|
||||||
writer.Print("world")
|
writer.Print("world")
|
||||||
// result:
|
// result:
|
||||||
// 02.01.06 15:04:05 hello world
|
// 02.01.06 15:04:05 hello world
|
||||||
|
|
||||||
writer.Close()
|
writer.Close()
|
||||||
// writes final \n if not written before
|
// writes final \n if not written before
|
||||||
```
|
```
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue