diff --git a/README.md b/README.md
index b46edd1d..99ad2ccd 100644
--- a/README.md
+++ b/README.md
@@ -21,17 +21,22 @@ Installation
如果还没有安装Go开发环境,请参考以下文档[Getting Started](http://golang.org/doc/install.html) ,安装完成后,请执行以下命令:
``` shell
-gopm get github.com/cihub/seelog -v -g
gopm get github.com/coocood/freecache -v -g
```
或者
``` shell
-go get -u github.com/cihub/seelog
go get -u github.com/coocood/freecache
```
+或者
+
+```shell
+chmod u+x ./depend.sh
+./depend.sh
+```
+
*请注意*: 最好使用Go 1.8进行开发
@@ -39,7 +44,8 @@ go get -u github.com/coocood/freecache
* 实时同步配置
* 灰度配置
* 客户端容灾
-* 配置文件容灾 (v1.6.0+)
+* 配置文件容灾 (v1.6.0+)
+* 自定义日志组件 (因开源协议原因,从v1.8.0不再存在默认日志组件。如还需使用seelog,请参考:[如何使用seelog](https://github.com/zouyx/agollo/wiki/%E4%BD%BF%E7%94%A8seelog%E6%97%A5%E5%BF%97%E7%BB%84%E4%BB%B6))
# Usage
@@ -67,7 +73,7 @@ func main() {
``` go
func main() {
- go agollo.StartWithLogger(loggerInterface)
+ agollo.StartWithLogger(loggerInterface)
}
```
@@ -75,7 +81,17 @@ func main() {
``` go
func main() {
- go agollo.StartWithCache(cacheInterface)
+ agollo.StartWithCache(cacheInterface)
+}
+```
+
+- 启动agollo - 自定义各种控件 (v1.8.0+)
+
+```go
+func main() {
+ agollo.SetLogger(loggerInterface)
+ agollo.SetCache(cacheInterface)
+ agollo.Start()
}
```
diff --git a/depend.sh b/depend.sh
index cc3c53c1..92e59d5d 100755
--- a/depend.sh
+++ b/depend.sh
@@ -1,2 +1 @@
-go get -u github.com/cihub/seelog
go get -u github.com/coocood/freecache
\ No newline at end of file
diff --git a/log.go b/log.go
index 2746ca98..08553162 100644
--- a/log.go
+++ b/log.go
@@ -1,13 +1,9 @@
package agollo
-import (
- "github.com/cihub/seelog"
-)
-
var logger LoggerInterface
func init() {
- initLogger(initSeeLog("seelog.xml"))
+ logger=&DefaultLogger{}
}
func initLogger(ILogger LoggerInterface) {
@@ -32,17 +28,38 @@ type LoggerInterface interface {
Error(v ...interface{}) error
}
-func initSeeLog(configPath string) LoggerInterface {
- logger, err := seelog.LoggerFromConfigAsFile(configPath)
+type DefaultLogger struct {
+}
- //if error is happen change to default config.
- if err != nil {
- logger, err = seelog.LoggerFromConfigAsBytes([]byte(""))
- }
+func (this *DefaultLogger)Debugf(format string, params ...interface{}) {
+
+}
- logger.SetAdditionalStackDepth(1)
- seelog.ReplaceLogger(logger)
- defer seelog.Flush()
+func (this *DefaultLogger)Infof(format string, params ...interface{}) {
- return logger
}
+
+
+func (this *DefaultLogger)Warnf(format string, params ...interface{}) error {
+ return nil
+}
+
+func (this *DefaultLogger)Errorf(format string, params ...interface{}) error {
+ return nil
+}
+
+
+func (this *DefaultLogger)Debug(v ...interface{}) {
+
+}
+func (this *DefaultLogger)Info(v ...interface{}){
+
+}
+
+func (this *DefaultLogger)Warn(v ...interface{}) error{
+ return nil
+}
+
+func (this *DefaultLogger)Error(v ...interface{}) error{
+ return nil
+}
\ No newline at end of file
diff --git a/log_test.go b/log_test.go
deleted file mode 100644
index 762d3199..00000000
--- a/log_test.go
+++ /dev/null
@@ -1,12 +0,0 @@
-package agollo
-
-import (
- "github.com/cihub/seelog"
- "testing"
-)
-
-func TestInitNullSeeLog(t *testing.T) {
- initSeeLog("joe.config")
-
- seelog.Error("good girl!")
-}
diff --git a/seelog.xml b/seelog.xml
deleted file mode 100644
index a12599af..00000000
--- a/seelog.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/start.go b/start.go
index a1512fa7..7f98d97a 100644
--- a/start.go
+++ b/start.go
@@ -2,25 +2,32 @@ package agollo
//start apollo
func Start() error {
- return StartWithLogger(nil)
+ return startAgollo()
}
-func StartWithLogger(loggerInterface LoggerInterface) error {
- return StartWithParams(loggerInterface,nil)
-}
-
-func StartWithCache(cacheInterface CacheInterface) error {
- return StartWithParams(nil,cacheInterface)
-}
-
-func StartWithParams(loggerInterface LoggerInterface,cacheInterface CacheInterface) error {
+func SetLogger(loggerInterface LoggerInterface) {
if loggerInterface != nil {
initLogger(loggerInterface)
}
+}
+
+func SetCache(cacheInterface CacheInterface) {
if cacheInterface != nil {
initCache(cacheInterface)
}
+}
+
+func StartWithLogger(loggerInterface LoggerInterface) error {
+ SetLogger(loggerInterface)
+ return startAgollo()
+}
+
+func StartWithCache(cacheInterface CacheInterface) error {
+ SetCache(cacheInterface)
+ return startAgollo()
+}
+func startAgollo() error {
//init server ip list
go initServerIpList()