Skip to content

test GHA #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,18 @@ jobs:
matrix:
os: [ubuntu, macos, windows]
golang: ['1.13', '1.16', '1.17']
# currently, we cannot run non-x86_64 machines on Github Actions cloud env.
# currently, we cannot run non-x86_64 machines on GitHub Actions cloud env.
runs-on: ${{ matrix.os }}-latest
name: CI golang ${{ matrix.golang }} on ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: ${{ matrix.golang }}
- name: Change GO11MODULES
run: go env -w GO111MODULE=auto
- name: Install requirements
run: |
go get github.com/bmizerany/assert
go get github.com/philhofer/fwd
go get github.com/tinylib/msgp
- name: Test
Expand Down
49 changes: 27 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ fluent-logger-golang

## How to install

```
go get github.com/fluent/fluent-logger-golang/fluent
```bash
go get github.com/fluent/fluent-logger-golang/fluent@latest
```

## Usage

Install the package with `go get` and use `import` to include it in your project.

```
```go
import "github.com/fluent/fluent-logger-golang/fluent"
```

Expand All @@ -26,27 +26,32 @@ import "github.com/fluent/fluent-logger-golang/fluent"
package main

import (
"github.com/fluent/fluent-logger-golang/fluent"
"fmt"
//"time"
"fmt"
"time"

"github.com/fluent/fluent-logger-golang/fluent"
)

func main() {
logger, err := fluent.New(fluent.Config{})
if err != nil {
fmt.Println(err)
}
defer logger.Close()
tag := "myapp.access"
var data = map[string]string{
"foo": "bar",
"hoge": "hoge",
}
error := logger.Post(tag, data)
// error := logger.PostWithTime(tag, time.Now(), data)
if error != nil {
panic(error)
}
logger, err := fluent.New(fluent.Config{})
if err != nil {
fmt.Println(err)
}
defer logger.Close()
tag := "myapp.access"
data := map[string]string{
"foo": "bar",
"hoge": "hoge",
}
err = logger.Post(tag, data)
if err != nil {
panic(err)
}

err = logger.PostWithTime(tag, time.Now(), data)
if err != nil {
panic(err)
}
}
```

Expand Down Expand Up @@ -181,7 +186,7 @@ were involved. Starting v1.8.0, the logger no longer accepts `Fluent.Post()`
after `Fluent.Close()`, and instead returns a "Logger already closed" error.

## Tests
```

```bash
go test
```
7 changes: 4 additions & 3 deletions _examples/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"log"
"time"

"../fluent"
"github.com/fluent/fluent-logger-golang/fluent"
)

func main() {
Expand All @@ -15,9 +15,10 @@ func main() {
}
defer logger.Close()
tag := "myapp.access"
var data = map[string]string{
data := map[string]string{
"foo": "bar",
"hoge": "hoge"}
"hoge": "hoge",
}
for i := 0; i < 100; i++ {
e := logger.Post(tag, data)
if e != nil {
Expand Down
46 changes: 22 additions & 24 deletions fluent/fluent.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package fluent

import (
"bytes"
"context"
"crypto/tls"
"encoding/base64"
"encoding/binary"
"encoding/json"
"errors"
"fmt"
Expand All @@ -15,10 +18,6 @@ import (
"sync"
"time"

"bytes"
"encoding/base64"
"encoding/binary"

"github.com/tinylib/msgp/msgp"
)

Expand Down Expand Up @@ -200,27 +199,26 @@ func newWithDialer(config Config, d dialer) (f *Fluent, err error) {
//
// Examples:
//
// // send map[string]
// mapStringData := map[string]string{
// "foo": "bar",
// }
// f.Post("tag_name", mapStringData)
//
// // send message with specified time
// mapStringData := map[string]string{
// "foo": "bar",
// }
// tm := time.Now()
// f.PostWithTime("tag_name", tm, mapStringData)
// // send map[string]
// mapStringData := map[string]string{
// "foo": "bar",
// }
// f.Post("tag_name", mapStringData)
//
// // send struct
// structData := struct {
// Name string `msg:"name"`
// } {
// "john smith",
// }
// f.Post("tag_name", structData)
// // send message with specified time
// mapStringData := map[string]string{
// "foo": "bar",
// }
// tm := time.Now()
// f.PostWithTime("tag_name", tm, mapStringData)
//
// // send struct
// structData := struct {
// Name string `msg:"name"`
// } {
// "john smith",
// }
// f.Post("tag_name", structData)
func (f *Fluent) Post(tag string, message interface{}) error {
timeNow := time.Now()
return f.PostWithTime(tag, timeNow, message)
Expand Down Expand Up @@ -317,7 +315,7 @@ func (chunk *MessageChunk) MarshalJSON() ([]byte, error) {
if err != nil {
return nil, err
}
return []byte(fmt.Sprintf("[\"%s\",%d,%s,%s]", chunk.message.Tag,
return []byte(fmt.Sprintf(`["%s",%d,%s,%s]`, chunk.message.Tag,
chunk.message.Time, data, option)), err
}

Expand Down
Loading