Skip to content

Commit 60d79de

Browse files
committed
Merge branch 'dev' of github.com:appbaseio/arc into dev
2 parents 16332d0 + a1a3fa9 commit 60d79de

50 files changed

Lines changed: 638 additions & 352 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ PLUGIN_MAIN_LOC_FUNC=plugins/$(1)/main/$(1).$(2)
99
PLUGIN_LOC_FUNC=$(foreach PLUGIN,$(PLUGINS),$(call PLUGIN_MAIN_LOC_FUNC,$(PLUGIN),$(1)))
1010

1111
cmd: plugins
12-
$(GC) -ldflags "-w -X main.Billing=$(BILLING) -X main.HostedBilling=$(HOSTED_BILLING) -X main.ClusterBilling=$(CLUSTER_BILLING) -X main.PlanRefreshInterval=$(PLAN_REFRESH_INTERVAL) -X main.IgnoreBillingMiddleware=$(IGNORE_BILLING_MIDDLEWARE)" -o $(BUILD_DIR)/arc main.go
12+
$(GC) -ldflags "-w -X main.Billing=$(BILLING) -X main.HostedBilling=$(HOSTED_BILLING) -X main.ClusterBilling=$(CLUSTER_BILLING) -X main.PlanRefreshInterval=$(PLAN_REFRESH_INTERVAL) -X main.IgnoreBillingMiddleware=$(IGNORE_BILLING_MIDDLEWARE) -X main.Tier=$(TEST_TIER) -X main.FeatureCustomEvents=$(TEST_FEATURE_CUSTOM_EVENTS) -X main.FeatureSuggestions=$(TEST_FEATURE_SUGGESTIONS)" -o $(BUILD_DIR)/arc main.go
1313

1414
plugins: $(call PLUGIN_LOC_FUNC,so)
1515

README.md

Lines changed: 41 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# Arc
22

3-
Arc is a simple, modular API Gateway that sits between a client and an [ElasticSearch](https://elastic.co) cluster. It acts as a reverse proxy, routing requests from clients to services. Arc is extended through plugins, which provide extra functionality and services beyond the ElasticSearch's RESTful API. It can perform various cross-cutting tasks such as basic authentication, logging, rate-limiting, source/referers whitelisting, analytics etc. These functionalities can clearly be extended by adding a plugin encapsulating a desired functionality. It also provides some useful abstractions that helps in managing and controlling the access
4-
to ElasticSearch's RESTful API.
3+
Arc is an API Gateway that sits between a client and an [ElasticSearch](https://elastic.co) cluster. It acts as a reverse proxy, routing requests from clients to services. Arc is extended through plugins, which provide extra functionality and services beyond the ElasticSearch's RESTful API. It can perform various cross-cutting tasks such as basic authentication, Role Based Access Control (using JWTs), logging, rate-limiting, source/referers whitelisting, analytics etc. These functionalities can clearly be extended by adding a plugin encapsulating a desired functionality. It also provides some useful abstractions that helps in managing and controlling the access to ElasticSearch's RESTful API.
54

65
## Table of contents
76
- [Overview](#overview)
@@ -15,10 +14,7 @@ to ElasticSearch's RESTful API.
1514
## Overview
1615

1716
When Arc is deployed, every client request being made to the Elasticsearch
18-
will hit Arc first and then be proxied to the Elasticsearch cluster. In between requests and responses, Arc
19-
may execute the installed plugins, essentially extending the Elasticsearch API feature set. Arc effectively
20-
becomes an entry point for every API request made to Elasticsearch. Arc can be used and deployed against any
21-
Elasticsearch cluster (locally and hosted as provided by [Appbase.io](https://appbase.io)).
17+
will hit Arc first and then be proxied to the Elasticsearch cluster. In between requests and responses, Arc may execute the installed plugins, essentially extending the Elasticsearch API feature set. Arc effectively becomes an entry point for every API request made to Elasticsearch. Arc can be used and deployed against any Elasticsearch cluster (locally and hosted as provided by [Appbase.io](https://appbase.io)).
2218

2319
```
2420
.------------------------------------------.
@@ -50,6 +46,7 @@ Elasticsearch cluster (locally and hosted as provided by [Appbase.io](https://ap
5046
## Installation
5147

5248
### Running it
49+
5350
In order to run arc, you'll require an Elasticsearch node. There are multiple ways you can [setup an Elasticsearch](https://www.elastic.co/guide/en/elasticsearch/reference/current/setup.html), either locally or remotely. We, however, are delineating the steps for local setup of a single node Elasticsearch via it's Docker image.
5451

5552
**Note**: The steps described here assumes a [docker](https://docs.docker.com/install/) installation on the system.
@@ -80,60 +77,73 @@ You can build the binary locally by executing the following command from the pro
8077

8178
This produces an executable & plugin libraries in the root project directory. To start the Arc server, run:
8279

83-
./build/arc --log=stdout --env=config/manual.env
80+
```bash
81+
./build/arc --env=config/manual.env --log=info
82+
```
8483

8584
Alternatively, you could execute the following commands to start the server without producing an executable, (but still produce the plugin libraries):
8685

8786
make plugins
88-
go run main.go --log=stdout --env=config/manual.env
87+
go run main.go --env=config/manual.env
88+
89+
90+
**Note**: Running the executable assumes an active Elasticsearch upstream whose URL is provided in the `.env` file.
8991

90-
**Note**: Running the executable assumes an active Elasticsearch connection whose url is to be provided in the `.env` file. manual.env configures it to be the localhost.
92+
### Logging
93+
Define the run time flag (`log`) to change the default log mode, the possible options are:
94+
95+
#### debug
96+
Most verbose, use this to get logs for elasticsearch interactions.
97+
#### info
98+
Prints the basic information
99+
#### error (default)
100+
Only log the errors
91101

92102
#### TLS Support
93103

94-
You can optionally start arc to serve https requests instead of http requests using the flag https.
95-
You also need to provide the server key & certificate file location through the environment file.
96-
manual.env is configured to use demo server key & certificates, which work for localhost.
97-
go run main.go --log=stdout --env=config/manual.env --https
104+
You can optionally start arc to serve https requests instead of http requests using the flag https. You also need to provide the server key & certificate file location through the environment file. `config/manual.env` is configured to use demo server key & certificates, which work for localhost.
105+
106+
```bash
107+
go run main.go --log=info --env=config/manual.env --https
108+
```
98109

99-
If you wish to manually test TLS support at localhost,
100-
curl needs to be also passed an extra parameter providing the cacert, in this case.
110+
If you wish to manually test TLS support at localhost, curl needs to be also passed an extra parameter providing the cacert, in this case.
111+
112+
```bash
101113
curl https://foo:bar@localhost:8000/_user --cacert sample/rootCA.pem
114+
```
102115

103116
#### JWT Key Loading through HTTP
104117

105-
If you wish to test loading JWT Key through HTTP, you can use the following commands to start a HTTP
106-
server serving the key
118+
If you wish to test loading JWT Key through HTTP, you can use the following commands to start a HTTP server serving the key
119+
```bash
107120
cd sample
108121
python -m SimpleHTTPServer 8500
109-
122+
```
110123
Then start arc using the command:
111-
go run main.go --log=stdout --env=config/manual-http-jwt.env
124+
```bash
125+
go run main.go --log=info --env=config/manual-http-jwt.env
126+
```
127+
128+
Arc also exposes an API endpoint to set the key at runtime, so this need not be set initially.
112129

113130
#### Run Tests
114131

115-
Currently, tests are WIP and implemented for auth and logs modules. You can run tests using:
132+
Currently, tests are implemented for auth, permissions, users and billing modules. You can run tests using:
116133

117134
go test ./...
118135

119136
### Implementation
120137

121-
The functionality in Arc can extended via plugins. An Arc plugin can be considered as a service in itself; it can have its
122-
own set of routes that it handles (keeping in mind it doesn't overlap with existing routes of other plugins), its own chain of
123-
middleware and more importantly its own database it intends to interact with (in our case it is Elasticsearch). For example, one
124-
can easily have multiple plugins providing specific services that interact with more than one database. The plugin is responsible for its own request lifecycle in this case.
138+
The functionality in Arc can extended via plugins. An Arc plugin can be considered as a service in itself; it can have its own set of routes that it handles (keeping in mind it doesn't overlap with existing routes of other plugins), its own chain of middleware and more importantly its own database it intends to interact with (in our case it is Elasticsearch). For example, one can easily have multiple plugins providing specific services that interact with more than one database. The plugin is responsible for its own request lifecycle in this case.
125139

126-
However, it is not necessary for a plugin to define a set of routes for a service. A plugin can easily be a middleware
127-
that can be used by other plugins with no new defined routes whatsoever. A middleware can either interact with a database or
128-
not is an implementation choice, but the important point here is that a plugin can be used by other plugins as long as it
129-
doesn't end up being a cyclic dependency.
140+
However, it is not necessary for a plugin to define a set of routes for a service. A plugin can easily be a middleware that can be used by other plugins with no new defined routes whatsoever. A middleware can either interact with a database or not is an implementation choice, but the important point here is that a plugin can be used by other plugins as long as it doesn't end up being a cyclic dependency.
130141

131142
Each plugin is structured in a particular way for brevity. Refer to the plugin [docs](https://github.com/appbaseio/arc/blob/master/docs/plugins.md) which describes a basic plugin implementation.
132143

133144
### Abstractions
134145

135-
Since every request made to Elasticsearch hits Arc first, it becomes beneficial to provide a set of abstractions that allows
136-
the client to define control over the Elasticsearch RESTful API and Arc's functionality. Arc provides several essential abstractions that are required in order to interact with Elasticsearch and Arc itself.
146+
Since every request made to Elasticsearch hits Arc first, it becomes beneficial to provide a set of abstractions that allows the client to define control over the Elasticsearch RESTful API and Arc's functionality. Arc provides several essential abstractions that are required in order to interact with Elasticsearch and Arc itself.
137147

138148
## Available Plugins
139149

@@ -153,7 +163,7 @@ In order to interact with Arc, the client must define a `User`. A `User` encapsu
153163

154164
### Permission
155165

156-
A `User` grants a `Permission` to a certain `User`, predefining its capabilities, in order to access Elasticsearch's RESTful API. Permissions serve as an entrypoint for accessing the Elasticsearch API and has a fixed *time-to-live* unlike a user, after which it will no longer be operational. A `User` is always in charge of the `Permission` it creates.
166+
A `User` grants a `Permission` to a certain `User`, predefining its capabilities in order to access Elasticsearch's RESTful API. Permissions serve as an entry point for accessing the Elasticsearch API and has a fixed *time-to-live* unlike a user, after which it will no longer be operational. A `User` is always in charge of the `Permission` they create.
157167

158168
- `username`: an auto generated username that uniquely identifies the permission
159169
- `password`: an auto generated password that verifies the identity of the permission

go.mod

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@ require (
66
github.com/gobuffalo/packr v1.22.0
77
github.com/google/uuid v1.0.0
88
github.com/gorilla/mux v1.7.1
9-
github.com/hashicorp/go-hclog v0.10.0 // indirect
109
github.com/hashicorp/go-retryablehttp v0.6.3
1110
github.com/olivere/elastic v6.2.21+incompatible
1211
github.com/olivere/elastic/v7 v7.0.4
1312
github.com/robfig/cron v1.1.0
1413
github.com/rogpeppe/go-internal v1.2.2 // indirect
1514
github.com/rs/cors v1.6.0
15+
github.com/siddharthlatest/mustache v0.0.0-20160118163553-00029677272d
16+
github.com/sirupsen/logrus v1.4.2
1617
github.com/smartystreets/goconvey v1.6.4
1718
github.com/ulule/limiter v2.2.0+incompatible
1819
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2

go.sum

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ github.com/gorilla/sessions v1.1.2/go.mod h1:8KCfur6+4Mqcc6S0FEfKuN15Vl5MgXW92AE
239239
github.com/gorilla/sessions v1.1.3/go.mod h1:8KCfur6+4Mqcc6S0FEfKuN15Vl5MgXW92AE8ovaJD0w=
240240
github.com/hashicorp/go-cleanhttp v0.5.1 h1:dH3aiDG9Jvb5r5+bYHsikaOUIpcM0xvgMXVoDkXMzJM=
241241
github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80=
242+
github.com/hashicorp/go-hclog v0.9.2 h1:CG6TE5H9/JXsFWJCfoIVpKFIkFe6ysEuHirp4DxCsHI=
242243
github.com/hashicorp/go-hclog v0.9.2/go.mod h1:5CU+agLiy3J7N7QjHK5d05KxGsuXiQLrjA0H7acj2lQ=
243244
github.com/hashicorp/go-hclog v0.10.0 h1:b86HUuA126IcSHyC55WjPo7KtCOVeTCKIjr+3lBhPxI=
244245
github.com/hashicorp/go-hclog v0.10.0/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ=
@@ -355,11 +356,14 @@ github.com/shurcooL/highlight_diff v0.0.0-20170515013008-09bb4053de1b/go.mod h1:
355356
github.com/shurcooL/highlight_go v0.0.0-20170515013102-78fb10f4a5f8/go.mod h1:UDKB5a1T23gOMUJrI+uSuH0VRDStOiUVSjBTRDVBVag=
356357
github.com/shurcooL/octicon v0.0.0-20180602230221-c42b0e3b24d9/go.mod h1:eWdoE5JD4R5UVWDucdOPg1g2fqQRq78IQa9zlOV1vpQ=
357358
github.com/shurcooL/sanitized_anchor_name v0.0.0-20170918181015-86672fcb3f95/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
359+
github.com/siddharthlatest/mustache v0.0.0-20160118163553-00029677272d/go.mod h1:ej02m5sGsrB5WBnM5xLGTfxUInBAbfNFPAsoJxBjn50=
358360
github.com/sirupsen/logrus v1.0.6/go.mod h1:pMByvHTf9Beacp5x1UXfOR9xyW/9antXMhjMPG0dEzc=
359361
github.com/sirupsen/logrus v1.1.0/go.mod h1:zrgwTnHtNr00buQ1vSptGe8m1f/BbgsPukg8qsT7A+A=
360362
github.com/sirupsen/logrus v1.1.1/go.mod h1:zrgwTnHtNr00buQ1vSptGe8m1f/BbgsPukg8qsT7A+A=
361363
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
362364
github.com/sirupsen/logrus v1.3.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
365+
github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4=
366+
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
363367
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM=
364368
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
365369
github.com/smartystreets/go-aws-auth v0.0.0-20180515143844-0c1422d1fdb9/go.mod h1:SnhjPscd9TpLiy1LpzGSKh3bXCfxxXuqd9xmQJy3slM=
@@ -459,6 +463,8 @@ golang.org/x/sys v0.0.0-20190102155601-82a175fd1598/go.mod h1:STP8DvDyc/dI5b8T5h
459463
golang.org/x/sys v0.0.0-20190116161447-11f53e031339/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
460464
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
461465
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
466+
golang.org/x/sys v0.0.0-20190422165155-953cdadca894 h1:Cz4ceDQGXuKRnVBDTS23GTn/pU5OE2C0WrNTOYK1Uuc=
467+
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
462468
golang.org/x/sys v0.0.0-20191008105621-543471e840be h1:QAcqgptGM8IQBC9K/RC4o+O9YmqEm0diQn9QmZw/0mU=
463469
golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
464470
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=

main.go

Lines changed: 59 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,16 @@ package main
22

33
import (
44
"bufio"
5+
"encoding/json"
56
"flag"
67
"fmt"
78
"io"
8-
"io/ioutil"
9-
"log"
109
"net/http"
1110
"os"
11+
"path"
1212
"path/filepath"
1313
"plugin"
14+
"runtime"
1415
"strconv"
1516
"strings"
1617

@@ -22,14 +23,14 @@ import (
2223
"github.com/robfig/cron"
2324
"github.com/rs/cors"
2425

25-
"gopkg.in/natefinch/lumberjack.v2"
26+
log "github.com/sirupsen/logrus"
2627
)
2728

2829
const logTag = "[cmd]"
2930

3031
var (
3132
envFile string
32-
logFile string
33+
logMode string
3334
listPlugins bool
3435
address string
3536
port int
@@ -45,11 +46,18 @@ var (
4546
ClusterBilling string
4647
// IgnoreBillingMiddleware ignores the billing middleware
4748
IgnoreBillingMiddleware string
49+
50+
// Tier for testing
51+
Tier string
52+
// FeatureCustomEvents for testing
53+
FeatureCustomEvents string
54+
// FeatureSuggestions for testing
55+
FeatureSuggestions string
4856
)
4957

5058
func init() {
5159
flag.StringVar(&envFile, "env", ".env", "Path to file with environment variables to load in KEY=VALUE format")
52-
flag.StringVar(&logFile, "log", "", "Process log file")
60+
flag.StringVar(&logMode, "log", "", "Define to change the default log mode(error), other options are: debug(most verbose) and info")
5361
flag.BoolVar(&listPlugins, "plugins", false, "List currently registered plugins")
5462
flag.StringVar(&address, "addr", "", "Address to serve on")
5563
flag.IntVar(&port, "port", 8000, "Port number")
@@ -59,27 +67,29 @@ func init() {
5967

6068
func main() {
6169
flag.Parse()
70+
log.SetReportCaller(true)
71+
log.SetFormatter(&log.TextFormatter{
72+
FullTimestamp: true,
73+
TimestampFormat: "2006/01/02 15:04:05",
74+
DisableLevelTruncation: true,
75+
CallerPrettyfier: func(f *runtime.Frame) (string, string) {
76+
filename := path.Base(f.File)
77+
return "", fmt.Sprintf(" %s:%d", filename, f.Line)
78+
},
79+
})
6280

63-
log.SetFlags(log.LstdFlags | log.Lshortfile)
64-
switch logFile {
65-
case "stdout":
66-
log.SetOutput(os.Stdout)
67-
case "stderr":
68-
log.SetOutput(os.Stderr)
69-
case "":
70-
log.SetOutput(ioutil.Discard)
81+
switch logMode {
82+
case "debug":
83+
log.SetLevel(log.DebugLevel)
84+
case "info":
85+
log.SetLevel(log.InfoLevel)
7186
default:
72-
log.SetOutput(&lumberjack.Logger{
73-
Filename: logFile,
74-
MaxSize: 100,
75-
MaxAge: 14,
76-
MaxBackups: 10,
77-
})
87+
log.SetLevel(log.ErrorLevel)
7888
}
7989

8090
// Load all env vars from envFile
8191
if err := LoadEnvFromFile(envFile); err != nil {
82-
log.Printf("%s: reading env file %q: %v", logTag, envFile, err)
92+
log.Errorln(logTag, ": reading env file", envFile, ": ", err)
8393
}
8494

8595
router := mux.NewRouter().StrictSlash(true)
@@ -89,7 +99,7 @@ func main() {
8999
} else {
90100
_, err := strconv.Atoi(PlanRefreshInterval)
91101
if err != nil {
92-
log.Fatal("PLAN_REFRESH_INTERVAL must be an integer")
102+
log.Fatal("PLAN_REFRESH_INTERVAL must be an integer: ", err)
93103
}
94104
}
95105

@@ -128,11 +138,36 @@ func main() {
128138
router.Use(util.BillingMiddleware)
129139
}
130140
} else {
131-
var plan = util.ArcEnterprise
132-
util.Tier = &plan
141+
util.SetDefaultTier()
133142
log.Println("You're running Arc with billing module disabled.")
134143
}
135144

145+
// Testing Env: Set variables based on the build blags
146+
if Tier != "" {
147+
var temp1 = map[string]interface{}{
148+
"tier": Tier,
149+
}
150+
type Temp struct {
151+
Tier *util.Plan `json:"tier"`
152+
}
153+
temp2 := Temp{}
154+
mashalled, err := json.Marshal(temp1)
155+
if err != nil {
156+
log.Fatal(err)
157+
}
158+
err = json.Unmarshal(mashalled, &temp2)
159+
if err != nil {
160+
log.Fatal(err)
161+
}
162+
util.SetTier(temp2.Tier)
163+
}
164+
if FeatureCustomEvents != "" && FeatureCustomEvents == "true" {
165+
util.SetFeatureCustomEvents(true)
166+
}
167+
if FeatureSuggestions != "" && FeatureSuggestions == "true" {
168+
util.SetFeatureSuggestions(true)
169+
}
170+
136171
// ES client instantiation
137172
// ES v7 and v6 clients
138173
util.NewClient()
@@ -170,7 +205,7 @@ func main() {
170205

171206
// Listen and serve ...
172207
addr := fmt.Sprintf("%s:%d", address, port)
173-
log.Printf("%s: listening on %s", logTag, addr)
208+
log.Println(logTag, ":listening on", addr)
174209
if https {
175210
httpsCert := os.Getenv("HTTPS_CERT")
176211
httpsKey := os.Getenv("HTTPS_KEY")

middleware/interceptor/interceptor.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
package interceptor
22

33
import (
4-
"log"
54
"net/http"
65
"net/url"
76
"os"
87

8+
log "github.com/sirupsen/logrus"
9+
910
"github.com/appbaseio/arc/errors"
1011
"github.com/appbaseio/arc/middleware"
1112
"github.com/appbaseio/arc/util"
@@ -26,12 +27,12 @@ func redirect(h http.HandlerFunc) http.HandlerFunc {
2627
rawURL := os.Getenv("ES_CLUSTER_URL")
2728
if rawURL == "" {
2829
err := errors.NewEnvVarNotSetError(envEsClusterURL)
29-
log.Printf("%s: %v", logTag, err)
30+
log.Errorln(logTag, ":", err)
3031
return
3132
}
3233
esURL, err := url.Parse(rawURL)
3334
if err != nil {
34-
log.Printf("%s: error parsing %s=%s: %v", logTag, rawURL, envEsClusterURL, err)
35+
log.Errorln(logTag, ":error parsing", rawURL, "=", envEsClusterURL, ":", err)
3536
return
3637
}
3738

@@ -41,7 +42,7 @@ func redirect(h http.HandlerFunc) http.HandlerFunc {
4142

4243
req, err := redirectRequest(r)
4344
if err != nil {
44-
log.Printf("%s: %v\n", logTag, err)
45+
log.Errorln(logTag, ":", err)
4546
util.WriteBackError(w, err.Error(), http.StatusInternalServerError)
4647
return
4748
}

middleware/logger/logger.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package logger
22

33
import (
44
"fmt"
5-
"log"
5+
log "github.com/sirupsen/logrus"
66
"net/http"
77
"strings"
88
"time"

0 commit comments

Comments
 (0)