@@ -61,7 +61,7 @@ import (
6161 "syscall"
6262 "unsafe"
6363
64- "github.com/sirupsen/logrus "
64+ "code.cloudfoundry.org/lager "
6565)
6666
6767// Quota limit params - currently we only control blocks hard limit
@@ -73,6 +73,7 @@ type Quota struct {
7373// Control - Context to be used by storage driver (e.g. overlay)
7474// who wants to apply project quotas to container dirs
7575type Control struct {
76+ logger lager.Logger
7677 backingFsBlockDev string
7778 nextProjectID uint32
7879 quotas map [string ]uint32
@@ -100,7 +101,8 @@ type Control struct {
100101// on it. If that works, continue to scan existing containers to map allocated
101102// project ids.
102103//
103- func NewControl (basePath string ) (* Control , error ) {
104+ func NewControl (logger lager.Logger , basePath string ) (* Control , error ) {
105+ logger = logger .Session ("projectquota" )
104106 //
105107 // Get project id of parent dir as minimal id to be used by driver
106108 //
@@ -130,6 +132,7 @@ func NewControl(basePath string) (*Control, error) {
130132 }
131133
132134 q := Control {
135+ logger : logger ,
133136 backingFsBlockDev : backingFsBlockDev ,
134137 nextProjectID : minProjectID + 1 ,
135138 quotas : make (map [string ]uint32 ),
@@ -143,7 +146,7 @@ func NewControl(basePath string) (*Control, error) {
143146 return nil , err
144147 }
145148
146- logrus . Debugf ( "NewControl(%s): nextProjectID = %d " , basePath , q .nextProjectID )
149+ q . logger . Debug ( "quota-control-created " , lager. Data { " basePath" : basePath , "projectID" : q .nextProjectID } )
147150 return & q , nil
148151}
149152
@@ -169,7 +172,7 @@ func (q *Control) SetQuota(nextProjectID uint32, targetPath string, quota Quota)
169172 //
170173 // set the quota limit for the container's project id
171174 //
172- logrus . Debugf ( "SetQuota(%s, %d): projectID=%d" , targetPath , quota .Size , projectID )
175+ q . logger . Debug ( "set-quota" , lager. Data { "targetPath" : targetPath , " quota" : quota .Size , " projectID" : projectID } )
173176 return setProjectQuota (q .backingFsBlockDev , projectID , quota )
174177}
175178
@@ -228,7 +231,7 @@ func (q *Control) GetQuota(targetPath string, quota *Quota) error {
228231}
229232
230233// GetProjectID - get the project id of path on xfs
231- func GetProjectID (targetPath string ) (uint32 , error ) {
234+ func GetProjectID (targetPath string ) (projId uint32 , err error ) {
232235 dir , err := openDir (targetPath )
233236 if err != nil {
234237 return 0 , err
0 commit comments