Make api logger work

This commit is contained in:
Kishan Mohanbhai Sagathiya 2019-08-29 20:49:53 +05:30
parent 49af782444
commit d43c8fb4a4
2 changed files with 7 additions and 4 deletions

View File

@ -50,7 +50,10 @@ func init() {
rand.Seed(time.Now().UnixNano())
}
var logger = logging.Logger("restapi")
var (
logger = logging.Logger("restapi")
apiLogger = logging.Logger("restapilog")
)
// Common errors
var (
@ -105,11 +108,10 @@ type peerAddBody struct {
}
type logWriter struct {
logger logging.EventLogger
}
func (lw logWriter) Write(b []byte) (int, error) {
lw.logger.Infof(string(b))
apiLogger.Infof(string(b))
return len(b), nil
}
@ -152,7 +154,7 @@ func NewAPIWithHost(ctx context.Context, cfg *Config, h host.Host) (*API, error)
}
writer = f
} else {
writer = logWriter{logger: logging.Logger("restapilog")}
writer = logWriter{}
}
s := &http.Server{

View File

@ -24,6 +24,7 @@ func init() {
var LoggingFacilities = map[string]string{
"cluster": "INFO",
"restapi": "INFO",
"restapilog": "INFO",
"ipfsproxy": "INFO",
"ipfshttp": "INFO",
"monitor": "INFO",