Skip to content

Navigation Menu

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 a28595b

Browse filesBrowse files
committed
Added ContextLogger to controller.
On controller creation a logger is attached to the controller, this logger has contextual information like the clientIp, request path, etc etc. Every log message sent to this logger will add this to the log message Added ability to log to json files. If log file ends in json then the logger will write to that file Added ability to define logger.maxsize (in mega bytes) defaults to 10G Added ability to define logger.maxage (in days) defaults to 7 If either of those values are exceeded the log file is rotated - ie the old is renamed and a new one is created Logger implementation is contained inside of the revel/logger package Added defaults so logging was not discarded (when used by the revel harness)
1 parent ef181a0 commit a28595b
Copy full SHA for a28595b

11 files changed

+570
-374
lines changed

‎controller.go

Copy file name to clipboardExpand all lines: controller.go
+3-5Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
"runtime"
1616
"strings"
1717
"time"
18+
"github.com/revel/revel/logger"
1819
)
1920

2021
// Controller Revel's controller structure that gets embedded in user defined
@@ -38,7 +39,7 @@ type Controller struct {
3839
Args map[string]interface{} // Per-request scratch space.
3940
ViewArgs map[string]interface{} // Variables passed to the template.
4041
Validation *Validation // Data validation helpers
41-
Log MultiLogger // Context Logger
42+
Log logger.MultiLogger // Context Logger
4243
}
4344

4445
// The map of controllers, controllers are mapped by using the namespace|controller_name as the key
@@ -373,7 +374,7 @@ func (c *Controller) SetTypeAction(controllerName, methodName string, typeOfCont
373374

374375
// Update Logger with controller and namespace
375376
if c.Log != nil {
376-
c.Log = c.Log.New("controller", c.Action, "namespace", c.Type.Namespace)
377+
c.Log = c.Log.New("action", c.Action, "namespace", c.Type.Namespace)
377378
}
378379

379380
if _, ok := cachedControllerMap[c.Name]; !ok {
@@ -390,9 +391,6 @@ func (c *Controller) SetTypeAction(controllerName, methodName string, typeOfCont
390391
c.AppController = cachedControllerMap[c.Name].Pop()
391392
c.setAppControllerFields()
392393

393-
// Assign the controller in the viewargs
394-
c.ViewArgs["_controller"] = c.AppController
395-
396394
return nil
397395
}
398396

0 commit comments

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