Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 02f2390

Browse filesBrowse files
committed
Cleanup
Remove unused module attribute in controller Changed module logger to use root log Moved log assignment from engine to router
1 parent a572ac3 commit 02f2390
Copy full SHA for 02f2390

File tree

4 files changed

+8
-7
lines changed
Filter options

4 files changed

+8
-7
lines changed

‎controller.go

Copy file name to clipboardExpand all lines: controller.go
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ type Controller struct {
2828
AppController interface{} // The controller that was instantiated. embeds revel.Controller
2929
Action string // The fully qualified action name, e.g. "App.Index"
3030
ClientIP string // holds IP address of request came from
31-
module *Module // The module for the parent controller (if available)
3231

3332
Request *Request
3433
Response *Response

‎module.go

Copy file name to clipboardExpand all lines: module.go
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ func addModule(name, importPath, modulePath string) {
144144
if _, found := ModuleByName(name); found {
145145
moduleLogger.Panic("Attempt to import duplicate module %s path %s aborting startup", "name", name, "path", modulePath)
146146
}
147-
Modules = append(Modules, &Module{Name: name, ImportPath: importPath, Path: modulePath, Log:AppLog.New("module", name)})
147+
Modules = append(Modules, &Module{Name: name, ImportPath: importPath, Path: modulePath, Log:RootLog.New("module", name)})
148148
if codePath := filepath.Join(modulePath, "app"); DirExists(codePath) {
149149
CodePaths = append(CodePaths, codePath)
150150
if viewsPath := filepath.Join(modulePath, "app", "views"); DirExists(viewsPath) {

‎router.go

Copy file name to clipboardExpand all lines: router.go
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -749,6 +749,12 @@ func RouterFilter(c *Controller, fc []Filter) {
749749

750750
// Add the route and fixed params to the Request Params.
751751
c.Params.Route = route.Params
752+
// Assign logger if from module
753+
if c.Type.ModuleSource!=nil && c.Type.ModuleSource!=appModule {
754+
c.Log = c.Type.ModuleSource.Log.New("ip", c.ClientIP,
755+
"path", c.Request.URL.Path, "method", c.Request.Method)
756+
}
757+
752758

753759
// Add the fixed parameters mapped by name.
754760
// TODO: Pre-calculate this mapping.

‎server-engine.go

Copy file name to clipboardExpand all lines: server-engine.go
+1-5Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -139,11 +139,7 @@ func handleInternal(ctx ServerContext) {
139139
}()
140140

141141
c.ClientIP = clientIP
142-
controllerLog := AppLog
143-
if c.module!=nil {
144-
controllerLog = c.module.Log
145-
}
146-
c.Log = controllerLog.New("ip", clientIP,
142+
c.Log = AppLog.New("ip", clientIP,
147143
"path", req.GetPath(), "method", req.Method)
148144
// Call the first filter, this will process the request
149145
Filters[0](c, Filters[1:])

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.