From d513bc565782965d66c6307bfefe21dc3fd36c1a Mon Sep 17 00:00:00 2001 From: Robin Krahl Date: Sat, 27 Jun 2015 21:12:01 +0200 Subject: Add a configuration section to the plugin information dialog. Customize the plugin information dialog and add a configuration section. In this section, the user may enable or disable logging. - create MediaWikiPluginInfoProvider to customize the plugin information dialog - add MediaWikiPluginInfoProvider to Info to activate it - enable or disable logging in MediaWikiUtils according to the configuration - update the localization See #31. --- mediawiki.lrdevplugin/MediaWikiUtils.lua | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'mediawiki.lrdevplugin/MediaWikiUtils.lua') 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 -- cgit v1.2.1