@@ -16,17 +16,22 @@ Reload your automation scripts to generate a new configuration file.]]
1616 badKey : " Can't %s section because the key #%d (%s) leads to a %s."
1717 jsonRoot : " JSON root element must be an array or a hashtable, got a %s."
1818 noFile : " No config file defined."
19- failedLockWrite : " Failed to lock config file for writing : %s"
19+ failedLock : " Failed to lock config file for %s : %s"
2020 waitLockFailed : " Error waiting for existing lock to be released: %s"
2121 forceReleaseFailed : " Failed to force-release existing lock after timeout had passed (%s)"
2222 noLock : " #{@@__name} doesn't have a lock"
2323 writeFailedRead : " Failed reading config file: %s."
2424 lockTimeout : " Timeout reached while waiting for write lock."
2525 }
2626 traceMsgs = {
27- waitingLock : " Waiting %d ms before trying to get a lock..."
28- waitingLock : " Waiting for config file lock to be released (%d seconds passed)... "
29- waitingLockFinished : " Lock was released after %d seconds."
27+ -- waitingLockPre: "Waiting %d ms before trying to get a lock..."
28+ waitingLock : " Waiting for config file lock to be released (%d ms passed)... "
29+ waitingLockFinished : " Lock was released after %d ms."
30+ mergeSectionStart : " Merging own section into configuration. Own Section: %s\n Configuration: %s"
31+ mergeSectionResult : " Merge completed with result: %s"
32+ fileNotFound : " Couldn't find config file '%s'."
33+ fileCreate : " Config file '%s' doesn't exist, yet. Will write a fresh copy containing the current configuration section."
34+ writing : " Writing config file '%s'..."
3035 -- waitingLockTimeout: "Timeout was reached after %d seconds, force-releasing lock..."
3136 }
3237
@@ -179,6 +184,9 @@ Reload your automation scripts to generate a new configuration file.]]
179184 return sectionExists
180185
181186 mergeSection : ( config) =>
187+ -- @logger\trace traceMsgs.mergeSectionStart, @logger\dumpToString(@section),
188+ -- @logger\dumpToString config
189+
182190 section, sectionExists = config, true
183191 -- create missing parent sections
184192 for i= 1 , # @section
@@ -198,6 +206,8 @@ Reload your automation scripts to generate a new configuration file.]]
198206 section[ k] = v for k, v in pairs @userConfig
199207 elseif sectionExists
200208 section[ @section [ # @section ]] = nil
209+
210+ -- @logger\trace traceMsgs.mergeSectionResult, @logger\dumpToString config
201211 return config
202212
203213 delete : ( concertWrite, waitLockTime) =>
@@ -210,13 +220,14 @@ Reload your automation scripts to generate a new configuration file.]]
210220 -- get a lock to avoid concurrent config file access
211221 time, err = @getLock waitLockTime
212222 unless time
213- return false , errors. failedLockWrite \ format err
223+ return false , errors. failedLock \ format " writing " , err
214224
215225 -- read the config file
216226 config, err = @readFile @file , false
217227 if config == false
218228 @releaseLock !
219229 return false , errors. writeFailedRead\ format err
230+ @logger \ trace traceMsgs. fileCreate, @file unless config
220231 config or= {}
221232
222233 -- merge in our section
@@ -241,8 +252,8 @@ Reload your automation scripts to generate a new configuration file.]]
241252 @releaseLock !
242253 return false , err
243254
244-
245- handle\ setvbuf " full"
255+ @logger \ trace traceMsgs . writing , @file
256+ handle\ setvbuf " full" , 10e6
246257 handle\ write res
247258 handle\ flush!
248259 handle\ close!
@@ -263,9 +274,11 @@ Reload your automation scripts to generate a new configuration file.]]
263274 success = mutex. tryLock!
264275 timeout -= checkInterval
265276 timePassed = waitTimeout - timeout
266- @logger \ trace traceMsgs. waitingLock, timePassed/ 1000
267- if timeout > 0
268- @logger \ trace traceMsgs. waitingLockFinished, timePassed/ 1000
277+ if timePassed % ( checkInterval* 5 ) == 0
278+ @logger \ trace traceMsgs. waitingLock, timePassed
279+
280+ if success
281+ @logger \ trace traceMsgs. waitingLockFinished, timePassed
269282 @hasLock = true
270283 return timePassed
271284 else
0 commit comments