Skip to content

Commit 9bb0e39

Browse files
authored
Merge pull request #405 from ondrej-fabry/fix-log-handlers
Fix log manager handlers
2 parents 61443be + 75d4460 commit 9bb0e39

File tree

4 files changed

+26
-6
lines changed

4 files changed

+26
-6
lines changed

.travis.yml

+10-3
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ sudo: required
44

55
language: go
66
go:
7-
- 1.10.x
7+
- "1.12.x"
8+
9+
go_import_path: github.com/ligato/cn-infra
810

911
addons:
1012
apt:
1113
packages:
1214
- npm
1315

14-
go_import_path: github.com/ligato/cn-infra
15-
1616
git:
1717
depth: 1
1818

@@ -33,3 +33,10 @@ script:
3333

3434
after_success:
3535
- goveralls -coverprofile=/tmp/coverage.out -service=travis-ci
36+
37+
notifications:
38+
slack:
39+
rooms:
40+
- ligato:QNOK2VgHH6k40T8nQxmSgRmo
41+
on_success: change
42+
on_failure: always

Makefile

+3-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,9 @@ clean-examples-plugin:
6767

6868
# Get test tools
6969
get-testtools:
70-
go get github.com/hashicorp/consul
70+
@echo "=> installing test tools"
71+
./scripts/install-consul.sh
72+
consul version
7173

7274
# Run tests
7375
test: get-testtools

logging/logmanager/plugin_impl_log_manager.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ func (p *Plugin) Init() error {
119119
// > curl -X PUT http://localhost:<port>/log/<logger-name>/<log-level>
120120
func (p *Plugin) AfterInit() error {
121121
if p.HTTP != nil {
122-
p.HTTP.RegisterHTTPHandler(fmt.Sprintf("/log/{%s}/{%s:debug|info|warn|error|fatal|panic}",
122+
p.HTTP.RegisterHTTPHandler(fmt.Sprintf("/log/{%s}/{%s}",
123123
loggerVarName, levelVarName), p.logLevelHandler, "PUT")
124124
p.HTTP.RegisterHTTPHandler("/log/list", p.listLoggersHandler, "GET")
125125
}
@@ -161,7 +161,7 @@ func (p *Plugin) logLevelHandler(formatter *render.Render) http.HandlerFunc {
161161
}
162162
err := p.setLoggerLogLevel(vars[loggerVarName], vars[levelVarName])
163163
if err != nil {
164-
formatter.JSON(w, http.StatusNotFound,
164+
formatter.JSON(w, http.StatusInternalServerError,
165165
struct{ Error string }{err.Error()})
166166
return
167167
}

scripts/install-consul.sh

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
set -e
3+
4+
CONSUL_VERSION=1.5.3
5+
6+
download_url=https://releases.hashicorp.com/consul/${CONSUL_VERSION}/consul_${CONSUL_VERSION}_linux_amd64.zip
7+
8+
wget -nv -O /tmp/consul.zip ${download_url}
9+
unzip -o /tmp/consul.zip -d /tmp/consul
10+
sudo mv /tmp/consul/consul /usr/local/bin
11+
rm -rf /tmp/consul.zip /tmp/consul

0 commit comments

Comments
 (0)