Skip to content

Commit

Permalink
Merge pull request #24 from tianxiaoliang/master
Browse files Browse the repository at this point in the history
github action
  • Loading branch information
tianxiaoliang authored Aug 27, 2020
2 parents 6959115 + e5d7679 commit d62e6d9
Show file tree
Hide file tree
Showing 12 changed files with 19 additions and 83 deletions.
16 changes: 1 addition & 15 deletions .github/workflows/static_check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ jobs:
run: go build -v .
- name: UT
run: |
bash scripts/ci/start_latest_sc.sh
go get github.com/stretchr/testify
bash scripts/ci/unit_test.sh
tests:
runs-on: ubuntu-latest
Expand All @@ -33,16 +31,4 @@ jobs:
id: go
- name: Fmt
run: |
bash scripts/ci/formatChecker.sh
- name: Misspell
run: |
go get -u github.com/client9/misspell/cmd/misspell
bash scripts/ci/formatChecker.sh
- name: Lint
run: |
go get -u golang.org/x/lint/golint
bash scripts/ci/goLintChecker.sh
- name: Cyclo
run: |
go get github.com/fzipp/gocyclo
bash scripts/ci/goCycloChecker.sh
bash scripts/ci/formatChecker.sh
2 changes: 1 addition & 1 deletion examples/native/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func main() {
})

logger := seclog.NewLogger("example")
rotate.RunLogRotate("test.log", &rotate.RotateConfig{}, logger)
rotate.RunLogRotate("test.log", &rotate.Config{}, logger)

logger.Debug("check-info", openlog.WithTags(openlog.Tags{
"info": "something",
Expand Down
9 changes: 4 additions & 5 deletions rotate/logrotate.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ func removeExceededFiles(path string, baseFileName string,
if maxKeptCount < 0 {
return
}
fileList := make([]string, 0, 2*maxKeptCount)
var pat string
if rotateStage == "rollover" {
//rotated file, svc.log.20060102150405000
Expand Down Expand Up @@ -304,16 +303,16 @@ func CopyFile(srcFile, destFile string) error {
return err
}

//RotateConfig is log rotate configs
type RotateConfig struct {
//Config is log rotate configs
type Config struct {
RollingPolicy string `yaml:"rollingPolicy"` // size or daily
LogRotateSize int `yaml:"logRotateSize"` //M Bytes.
LogBackupCount int `yaml:"logBackupCount"`
LogRotateDate int `yaml:"logRotateDate"` //hours
}

// RunLogRotate initialize log rotate
func RunLogRotate(logFilePath string, c *RotateConfig, logger lager.Logger) {
func RunLogRotate(logFilePath string, c *Config, logger lager.Logger) {
Logger = logger
if logFilePath == "" {
return
Expand Down Expand Up @@ -346,7 +345,7 @@ func RunLogRotate(logFilePath string, c *RotateConfig, logger lager.Logger) {
}

// checkPassLagerDefinition check pass lager definition
func checkConfig(c *RotateConfig) {
func checkConfig(c *Config) {
if c.RollingPolicy == "" {
log.Println("RollingPolicy is empty, use default policy[size]")
c.RollingPolicy = RollingPolicySize
Expand Down
File renamed without changes.
8 changes: 8 additions & 0 deletions scripts/ci/unit_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh
set -e
#Start unit test
for d in $(go list ./... | grep -v third_party| grep -v example); do
if [ $(ls | grep _test.go | wc -l) -gt 0 ]; then
go test $d -cover
fi
done
8 changes: 0 additions & 8 deletions scripts/travis/deadCodeChecker.sh

This file was deleted.

8 changes: 0 additions & 8 deletions scripts/travis/goConstChecker.sh

This file was deleted.

8 changes: 0 additions & 8 deletions scripts/travis/goCycloChecker.sh

This file was deleted.

8 changes: 0 additions & 8 deletions scripts/travis/goLintChecker.sh

This file was deleted.

8 changes: 0 additions & 8 deletions scripts/travis/misspellChecker.sh

This file was deleted.

19 changes: 0 additions & 19 deletions scripts/travis/unit_test.sh

This file was deleted.

8 changes: 5 additions & 3 deletions syslog/syslog.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,11 @@ func (r *Writer) Write(b []byte) (int, error) {
nl = "\n"
}

r.conn.SetWriteDeadline(time.Now().Add(1 * time.Second))

_, err := fmt.Fprintf(r.conn, " %s %s%s", syslogHeader, b, nl)
err := r.conn.SetWriteDeadline(time.Now().Add(1 * time.Second))
if err != nil {
return 0, err
}
_, err = fmt.Fprintf(r.conn, " %s %s%s", syslogHeader, b, nl)
if err != nil {
return 0, err
}
Expand Down

0 comments on commit d62e6d9

Please sign in to comment.