Skip to content

Commit

Permalink
Finish 0.0.6
Browse files Browse the repository at this point in the history
  • Loading branch information
zouyx committed Jul 28, 2017
2 parents 2869a54 + 1d7ee02 commit 4702119
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 22 deletions.
2 changes: 1 addition & 1 deletion app_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ package agollo
import (
"os"
"strconv"
"github.com/cihub/seelog"
"time"
"fmt"
"net/url"
"github.com/cihub/seelog"
)

const appConfigFileName ="app.properties"
Expand Down
2 changes: 1 addition & 1 deletion componet_notify.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ package agollo

import (
"time"
"github.com/cihub/seelog"
"net/http"
"io/ioutil"
"encoding/json"
"sync"
"errors"
"github.com/cihub/seelog"
)


Expand Down
2 changes: 1 addition & 1 deletion componet_timer.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"time"
"net/http"
"io/ioutil"
"github.com/cihub/seelog"
"errors"
"github.com/cihub/seelog"
)

type AutoRefreshConfigComponent struct {
Expand Down
22 changes: 22 additions & 0 deletions log.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package agollo

import (
"github.com/cihub/seelog"
)

func init(){
initSeeLog("seelog.xml")
}

func initSeeLog(configPath string) {
logger, err := seelog.LoggerFromConfigAsFile(configPath)

//if error is happen change to default config.
if err != nil {
logger, err = seelog.LoggerFromConfigAsBytes([]byte("<seelog />"))
}

logger.SetAdditionalStackDepth(1)
seelog.ReplaceLogger(logger)
defer seelog.Flush()
}
12 changes: 12 additions & 0 deletions log_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package agollo

import (
"testing"
"github.com/cihub/seelog"
)

func TestInitNullSeeLog(t *testing.T) {
initSeeLog("joe.config")

seelog.Error("good girl!")
}
6 changes: 1 addition & 5 deletions repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,9 @@ const (
)

var (
currentApolloConfig *ApolloConfig
currentApolloConfig *ApolloConfig=&ApolloConfig{}
)

func init(){
currentApolloConfig=&ApolloConfig{}
}

func updateApolloConfig(apolloConfig *ApolloConfig) {
currentApolloConfig.Lock()
defer currentApolloConfig.Unlock()
Expand Down
14 changes: 0 additions & 14 deletions utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"net"
"os"
"reflect"
"github.com/cihub/seelog"
)

var(
Expand Down Expand Up @@ -67,16 +66,3 @@ func isNilObject(object interface{}) bool {

return false
}

//log
func init(){
logger, err := seelog.LoggerFromConfigAsFile("seelog.xml")

if err != nil {
panic("init log fail,error!"+err.Error())
}

logger.SetAdditionalStackDepth(1)
seelog.ReplaceLogger(logger)
defer seelog.Flush()
}

0 comments on commit 4702119

Please sign in to comment.