aboutsummaryrefslogtreecommitdiff
path: root/mediawiki.lrdevplugin/MediaWikiUtils.lua
diff options
context:
space:
mode:
Diffstat (limited to 'mediawiki.lrdevplugin/MediaWikiUtils.lua')
-rw-r--r--mediawiki.lrdevplugin/MediaWikiUtils.lua21
1 files changed, 13 insertions, 8 deletions
diff --git a/mediawiki.lrdevplugin/MediaWikiUtils.lua b/mediawiki.lrdevplugin/MediaWikiUtils.lua
index 7d1dd8d..6727e3b 100644
--- a/mediawiki.lrdevplugin/MediaWikiUtils.lua
+++ b/mediawiki.lrdevplugin/MediaWikiUtils.lua
@@ -15,16 +15,13 @@
local LrLogger = import 'LrLogger'
local Info = require 'Info'
-local myLogger = LrLogger('LrMediaWikiLogger')
-
--- LOGGING
--- If enabled, the log file will appear in your "My Documents" folder. Warning:
--- LrMediaWiki will log all requests sent to MediaWiki, including your password!
--- If you share a log file, make sure you removed your password.
--- To enable logging, uncomment the following line:
--- myLogger:enable("logfile")
local MediaWikiUtils = {}
+local myLogger = LrLogger('LrMediaWikiLogger')
+local prefs = import 'LrPrefs'.prefsForPlugin()
+if prefs.logging then
+ myLogger:enable('logfile')
+end
-- Allows formatting of strings like "${test} eins zwei drei ${test2}"
-- Based on a solution by http://lua-users.org/wiki/RiciLake shown here:
@@ -45,6 +42,14 @@ MediaWikiUtils.getVersionString = function()
return str
end
+MediaWikiUtils.setLogging = function(logging)
+ if logging then
+ myLogger:enable('logfile')
+ else
+ myLogger:disable()
+ end
+end
+
MediaWikiUtils.trace = function(message)
myLogger:trace(message)
end