@@ -40,27 +40,36 @@ type Config struct {
40
40
}
41
41
42
42
func New (ctx * context.Context , cfg Config ) (manager Manager , err error ) {
43
- ctx = ctx .Field ("cfg " , cfg )
43
+ ctx = ctx .Field (":func " , "manager/New" )
44
44
45
45
ctx .
46
- Level (context .Info ).
47
- Message ("instantiating volume manager" )
46
+ Level (context .Debug ).
47
+ Field (":param/cfg" , cfg ).
48
+ Message ("invoked" )
48
49
49
50
defer func () {
50
51
if err != nil {
51
52
ctx .
52
53
Level (context .Error ).
53
- Field ("error " , err ).
54
+ Field (":return/err " , err ).
54
55
Message ("failed with an error while instantiating volume manager" )
55
56
return
56
57
} else {
57
58
ctx .
58
59
Level (context .Info ).
59
- Message ("finished instantiating volume manager" )
60
+ Message ("instantiated volume manager" )
61
+ ctx .
62
+ Level (context .Debug ).
63
+ Field (":return/manager" , manager ).
64
+ Message ("finished processing" )
60
65
}
61
66
}()
62
67
63
68
// state dir
69
+ ctx .
70
+ Level (context .Trace ).
71
+ Field ("StateDir" , cfg .StateDir ).
72
+ Message ("validating 'StateDir' config field" )
64
73
if cfg .StateDir == "" {
65
74
err = errors .Errorf ("StateDir is not specified." )
66
75
return
@@ -73,6 +82,10 @@ func New(ctx *context.Context, cfg Config) (manager Manager, err error) {
73
82
manager .stateDir = cfg .StateDir
74
83
75
84
// data dir
85
+ ctx .
86
+ Level (context .Trace ).
87
+ Field ("DataDir" , cfg .DataDir ).
88
+ Message ("validating 'DataDir' config field" )
76
89
if cfg .DataDir == "" {
77
90
err = errors .Errorf ("DataDir is not specified." )
78
91
return
@@ -85,6 +98,10 @@ func New(ctx *context.Context, cfg Config) (manager Manager, err error) {
85
98
manager .dataDir = cfg .DataDir
86
99
87
100
// mount dir
101
+ ctx .
102
+ Level (context .Trace ).
103
+ Field ("MountDir" , cfg .MountDir ).
104
+ Message ("validating 'MountDir' config field" )
88
105
if cfg .MountDir == "" {
89
106
err = errors .Errorf ("MountDir is not specified." )
90
107
return
@@ -111,12 +128,13 @@ func (m Manager) List(ctx *context.Context) (volumes []Volume, err error) {
111
128
if err != nil {
112
129
ctx .
113
130
Level (context .Error ).
114
- Field ("error" , err ).
131
+ Field (":return/ error" , err ).
115
132
Message ("failed with an error" )
116
133
return
117
134
} else {
118
135
ctx .
119
136
Level (context .Debug ).
137
+ Field (":return/volumes" , volumes ).
120
138
Message ("finished" )
121
139
}
122
140
}()
@@ -159,7 +177,7 @@ func (m Manager) List(ctx *context.Context) (volumes []Volume, err error) {
159
177
Field ("entry" , file .Name ())
160
178
161
179
ctx .
162
- Level (context .Debug ).
180
+ Level (context .Trace ).
163
181
Message ("processing entry" )
164
182
165
183
if file .Mode ().IsRegular () {
@@ -182,11 +200,6 @@ func (m Manager) List(ctx *context.Context) (volumes []Volume, err error) {
182
200
}
183
201
}
184
202
185
- ctx .
186
- Level (context .Debug ).
187
- Field ("count" , len (volumes )).
188
- Message ("volumes found" )
189
-
190
203
return
191
204
}
192
205
@@ -203,12 +216,13 @@ func (m Manager) Get(ctx *context.Context, name string) (volume Volume, err erro
203
216
if err != nil {
204
217
ctx .
205
218
Level (context .Error ).
206
- Field ("error " , err ).
219
+ Field (":return/err " , err ).
207
220
Message ("failed with an error" )
208
221
return
209
222
} else {
210
223
ctx .
211
224
Level (context .Debug ).
225
+ Field (":return/volume" , volume ).
212
226
Message ("finished" )
213
227
}
214
228
}()
@@ -255,7 +269,7 @@ func (m Manager) Create(ctx *context.Context, name string, sizeInBytes int64, sp
255
269
if err != nil {
256
270
ctx .
257
271
Level (context .Error ).
258
- Field ("error " , err ).
272
+ Field (":return/err " , err ).
259
273
Message ("failed with an error" )
260
274
return
261
275
} else {
@@ -308,7 +322,7 @@ func (m Manager) Create(ctx *context.Context, name string, sizeInBytes int64, sp
308
322
ctx .
309
323
Level (context .Trace ).
310
324
Field ("datta-dir" , m .dataDir ).
311
- Field ("mode" , dataDirMode ).
325
+ Field ("mode" , fmt . Sprintf ( "%#o" , dataDirMode ) ).
312
326
Message ("ensuring data-dir exists and creating it with proper mode if not" )
313
327
err = os .MkdirAll (m .dataDir , dataDirMode )
314
328
if err != nil {
@@ -446,7 +460,7 @@ func (m Manager) Create(ctx *context.Context, name string, sizeInBytes int64, sp
446
460
if mode > 0 {
447
461
ctx .
448
462
Level (context .Trace ).
449
- Field ("mode" , mode ).
463
+ Field ("mode" , fmt . Sprintf ( "%#o" , mode ) ).
450
464
Message ("adjusting volume's root mode with 'chmod' exec" )
451
465
452
466
var errStr string
@@ -491,12 +505,13 @@ func (m Manager) Mount(ctx *context.Context, name string, lease string) (result
491
505
if err != nil {
492
506
ctx .
493
507
Level (context .Error ).
494
- Field ("error " , err ).
508
+ Field (":return/err " , err ).
495
509
Message ("failed with an error" )
496
510
return
497
511
} else {
498
512
ctx .
499
513
Level (context .Debug ).
514
+ Field (":return/result" , result ).
500
515
Message ("finished" )
501
516
}
502
517
}()
@@ -628,7 +643,7 @@ func (m Manager) Mount(ctx *context.Context, name string, lease string) (result
628
643
var mountPointMode os.FileMode = 0777
629
644
ctx .
630
645
Level (context .Trace ).
631
- Field ("mode" , mountPointMode ).
646
+ Field ("mode" , fmt . Sprintf ( "%#o" , mountPointMode ) ).
632
647
Message ("creating mount-point" )
633
648
634
649
err = os .Mkdir (volume .MountPointPath , mountPointMode )
@@ -680,7 +695,7 @@ func (m Manager) UnMount(ctx *context.Context, name string, lease string) (err e
680
695
if err != nil {
681
696
ctx .
682
697
Level (context .Error ).
683
- Field ("error " , err ).
698
+ Field (":return/err " , err ).
684
699
Message ("failed with an error" )
685
700
return
686
701
} else {
@@ -795,7 +810,7 @@ func (m Manager) Delete(ctx *context.Context, name string) (err error) {
795
810
if err != nil {
796
811
ctx .
797
812
Level (context .Error ).
798
- Field ("error " , err ).
813
+ Field (":return/err " , err ).
799
814
Message ("failed with an error" )
800
815
return
801
816
} else {
@@ -867,25 +882,26 @@ func (m Manager) Delete(ctx *context.Context, name string) (err error) {
867
882
return
868
883
}
869
884
870
- func (m Manager ) getVolume (ctx * context.Context , name string ) (vol Volume , err error ) {
885
+ func (m Manager ) getVolume (ctx * context.Context , name string ) (volume Volume , err error ) {
871
886
ctx = ctx .
872
- Field (":func" , "manager/getVolume" ).
873
- Field (":param/name" , name )
887
+ Field (":func" , "manager/getVolume" )
874
888
875
889
ctx .
876
890
Level (context .Debug ).
891
+ Field (":param/name" , name ).
877
892
Message ("invoked" )
878
893
879
894
defer func () {
880
895
if err != nil {
881
896
ctx .
882
897
Level (context .Error ).
883
- Field ("error " , err ).
898
+ Field (":return/err " , err ).
884
899
Message ("failed with an error" )
885
900
return
886
901
} else {
887
902
ctx .
888
903
Level (context .Debug ).
904
+ Field (":return/volume" , volume ).
889
905
Message ("finished" )
890
906
}
891
907
}()
@@ -933,7 +949,7 @@ func (m Manager) getVolume(ctx *context.Context, name string) (vol Volume, err e
933
949
934
950
mountPointPath := filepath .Join (m .mountDir , name )
935
951
936
- vol = Volume {
952
+ volume = Volume {
937
953
Name : name ,
938
954
Fs : fs ,
939
955
AllocatedSizeInBytes : uint64 (details .Blocks * 512 ),
0 commit comments