Added better logging options to the GUI and Commandline
git-svn-id: https://duplicati.googlecode.com/svn/trunk@537 59da171f-624f-0410-aa54-27559c288bec
This commit is contained in:
@@ -58,6 +58,10 @@ namespace Duplicati.GUI
|
||||
public void ExecuteTask(IDuplicityTask task)
|
||||
{
|
||||
Dictionary<string, string> options = new Dictionary<string,string>();
|
||||
|
||||
//Set the log level to be that of the GUI
|
||||
options["log-level"] = Duplicati.Library.Logging.Log.LogLevel.ToString();
|
||||
|
||||
string destination = task.GetConfiguration(options);
|
||||
|
||||
string results = "";
|
||||
|
||||
+24
-11
@@ -162,6 +162,27 @@ namespace Duplicati.GUI
|
||||
return;
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
//Log various information in the logfile
|
||||
if (!commandlineOptions.ContainsKey("log-file"))
|
||||
{
|
||||
commandlineOptions["log-file"] = System.IO.Path.Combine(Application.StartupPath, "Duplicati.debug.log");
|
||||
commandlineOptions["log-level"] = Duplicati.Library.Logging.LogMessageType.Profiling.ToString();
|
||||
}
|
||||
#endif
|
||||
|
||||
if (commandlineOptions.ContainsKey("log-level"))
|
||||
foreach (string s in Enum.GetNames(typeof(Duplicati.Library.Logging.LogMessageType)))
|
||||
if (s.Equals(commandlineOptions["log-level"].Trim(), StringComparison.InvariantCultureIgnoreCase))
|
||||
Duplicati.Library.Logging.Log.LogLevel = (Duplicati.Library.Logging.LogMessageType)Enum.Parse(typeof(Duplicati.Library.Logging.LogMessageType), s);
|
||||
|
||||
if (commandlineOptions.ContainsKey("log-file"))
|
||||
{
|
||||
if (System.IO.File.Exists(commandlineOptions["log-file"]))
|
||||
System.IO.File.Delete(commandlineOptions["log-file"]);
|
||||
Duplicati.Library.Logging.Log.CurrentLog = new Duplicati.Library.Logging.StreamLog(commandlineOptions["log-file"]);
|
||||
}
|
||||
|
||||
//Set the %DUPLICATI_HOME% env variable, if it is not already set
|
||||
if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable(DATAFOLDER_ENV_NAME)))
|
||||
{
|
||||
@@ -258,16 +279,6 @@ namespace Duplicati.GUI
|
||||
//This is non-fatal, just keep running with system default language
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
//Log various information in the logfile
|
||||
string logfile = System.IO.Path.Combine(Application.StartupPath, "Duplicati.debug.log");
|
||||
if (System.IO.File.Exists(logfile))
|
||||
System.IO.File.Delete(logfile);
|
||||
|
||||
Duplicati.Library.Logging.Log.LogLevel = Duplicati.Library.Logging.LogMessageType.Profiling;
|
||||
Duplicati.Library.Logging.Log.CurrentLog = new Duplicati.Library.Logging.StreamLog(logfile);
|
||||
#endif
|
||||
|
||||
LiveControl = new LiveControls(new ApplicationSettings(DataConnection));
|
||||
LiveControl.StateChanged += new EventHandler(LiveControl_StateChanged);
|
||||
LiveControl.ThreadPriorityChanged += new EventHandler(LiveControl_ThreadPriorityChanged);
|
||||
@@ -472,7 +483,9 @@ namespace Duplicati.GUI
|
||||
new Duplicati.Library.Interface.CommandLineArgument("pause", Duplicati.Library.Interface.CommandLineArgument.ArgumentType.String, Strings.Program.PauseCommandDescription, Strings.Program.PauseCommandDescription),
|
||||
new Duplicati.Library.Interface.CommandLineArgument("show-status", Duplicati.Library.Interface.CommandLineArgument.ArgumentType.Boolean, Strings.Program.ShowstausCommandDescription, Strings.Program.ShowstausCommandDescription),
|
||||
new Duplicati.Library.Interface.CommandLineArgument("unencrypted-database", Duplicati.Library.Interface.CommandLineArgument.ArgumentType.Boolean, Strings.Program.UnencrypteddatabaseCommandDescription, Strings.Program.UnencrypteddatabaseCommandDescription),
|
||||
new Duplicati.Library.Interface.CommandLineArgument("portable-mode", Duplicati.Library.Interface.CommandLineArgument.ArgumentType.Boolean, Strings.Program.PortablemodeCommandDescription, Strings.Program.PortablemodeCommandDescription)
|
||||
new Duplicati.Library.Interface.CommandLineArgument("portable-mode", Duplicati.Library.Interface.CommandLineArgument.ArgumentType.Boolean, Strings.Program.PortablemodeCommandDescription, Strings.Program.PortablemodeCommandDescription),
|
||||
new Duplicati.Library.Interface.CommandLineArgument("log-file", Duplicati.Library.Interface.CommandLineArgument.ArgumentType.Path, Strings.Program.LogfileCommandDescription, Strings.Program.LogfileCommandDescription),
|
||||
new Duplicati.Library.Interface.CommandLineArgument("log-level", Duplicati.Library.Interface.CommandLineArgument.ArgumentType.Enumeration, Strings.Program.LoglevelCommandDescription, Strings.Program.LoglevelCommandDescription, "Warning", null, Enum.GetNames(typeof(Duplicati.Library.Logging.LogMessageType)))
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
+18
@@ -126,6 +126,24 @@ namespace Duplicati.GUI.Strings {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Outputs log information to the file given.
|
||||
/// </summary>
|
||||
internal static string LogfileCommandDescription {
|
||||
get {
|
||||
return ResourceManager.GetString("LogfileCommandDescription", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Determines the amount of information written in the log file.
|
||||
/// </summary>
|
||||
internal static string LoglevelCommandDescription {
|
||||
get {
|
||||
return ResourceManager.GetString("LoglevelCommandDescription", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Pauses Duplicati, supply a time eg. 5m to limit pause to 5 minutes.
|
||||
/// </summary>
|
||||
|
||||
@@ -144,6 +144,12 @@ Error message: {0}</value>
|
||||
<value>Failed to set the user interface language: {0}</value>
|
||||
<comment>An error message displayed if the language cannot be selected</comment>
|
||||
</data>
|
||||
<data name="LogfileCommandDescription" xml:space="preserve">
|
||||
<value>Outputs log information to the file given</value>
|
||||
</data>
|
||||
<data name="LoglevelCommandDescription" xml:space="preserve">
|
||||
<value>Determines the amount of information written in the log file</value>
|
||||
</data>
|
||||
<data name="PauseCommandDescription" xml:space="preserve">
|
||||
<value>Pauses Duplicati, supply a time eg. 5m to limit pause to 5 minutes</value>
|
||||
</data>
|
||||
|
||||
@@ -1260,6 +1260,11 @@ namespace Duplicati.Library.Main
|
||||
{
|
||||
m_options.MainAction = stats.OperationMode;
|
||||
|
||||
Library.Logging.Log.LogLevel = m_options.Loglevel;
|
||||
|
||||
if (!string.IsNullOrEmpty(m_options.Logfile))
|
||||
Library.Logging.Log.CurrentLog = new Library.Logging.StreamLog(m_options.Logfile);
|
||||
|
||||
if (stats != null)
|
||||
stats.VerboseErrors = m_options.DebugOutput;
|
||||
|
||||
|
||||
@@ -151,6 +151,9 @@ namespace Duplicati.Library.Main
|
||||
|
||||
new CommandLineArgument("debug-output", CommandLineArgument.ArgumentType.Boolean, Strings.Options.DebugoutputShort, Strings.Options.DebugoutputLong, "false"),
|
||||
new CommandLineArgument("exclude-empty-folders", CommandLineArgument.ArgumentType.Boolean, Strings.Options.ExcludeemptyfoldersShort, Strings.Options.ExcludeemptyfoldersLong, "false"),
|
||||
|
||||
new CommandLineArgument("log-file", Duplicati.Library.Interface.CommandLineArgument.ArgumentType.Path, Strings.Options.LogfileShort, Strings.Options.LogfileShort),
|
||||
new CommandLineArgument("log-level", Duplicati.Library.Interface.CommandLineArgument.ArgumentType.Enumeration, Strings.Options.LoglevelShort, Strings.Options.LoglevelLong, "Warning", null, Enum.GetNames(typeof(Duplicati.Library.Logging.LogMessageType))),
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -730,6 +733,39 @@ namespace Duplicati.Library.Main
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the logfile filename
|
||||
/// </summary>
|
||||
public string Logfile
|
||||
{
|
||||
get
|
||||
{
|
||||
string value;
|
||||
if (!m_options.TryGetValue("log-file", out value))
|
||||
value = null;
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the logfile filename
|
||||
/// </summary>
|
||||
public Duplicati.Library.Logging.LogMessageType Loglevel
|
||||
{
|
||||
get
|
||||
{
|
||||
string value;
|
||||
if (!m_options.TryGetValue("log-level", out value))
|
||||
value = null;
|
||||
|
||||
foreach (string s in Enum.GetNames(typeof(Duplicati.Library.Logging.LogMessageType)))
|
||||
if (s.Equals(value, StringComparison.InvariantCultureIgnoreCase))
|
||||
return (Duplicati.Library.Logging.LogMessageType)Enum.Parse(typeof(Duplicati.Library.Logging.LogMessageType), s);
|
||||
|
||||
return Duplicati.Library.Logging.LogMessageType.Warning;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a list of modules, the key indicates if they are loaded
|
||||
/// </summary>
|
||||
|
||||
+36
@@ -537,6 +537,42 @@ namespace Duplicati.Library.Main.Strings {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Specifies the name of a while into which internal log information is written.
|
||||
/// </summary>
|
||||
internal static string LogfileLong {
|
||||
get {
|
||||
return ResourceManager.GetString("LogfileLong", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Log internal information.
|
||||
/// </summary>
|
||||
internal static string LogfileShort {
|
||||
get {
|
||||
return ResourceManager.GetString("LogfileShort", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Specifies the amount of log information to write into the file specified by --log-file.
|
||||
/// </summary>
|
||||
internal static string LoglevelLong {
|
||||
get {
|
||||
return ResourceManager.GetString("LoglevelLong", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Log information level.
|
||||
/// </summary>
|
||||
internal static string LoglevelShort {
|
||||
get {
|
||||
return ResourceManager.GetString("LoglevelShort", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to By setting this value you can limit how much bandwidth Duplicati consumes for downloads. Setting this limit can make the backups take longer, but will make Duplicati less intrusive..
|
||||
/// </summary>
|
||||
|
||||
@@ -399,4 +399,16 @@
|
||||
<data name="TimeseparatorDeprecated" xml:space="preserve">
|
||||
<value>Duplicati no longer uses a time separator for the filenames so this option is useless</value>
|
||||
</data>
|
||||
<data name="LogfileLong" xml:space="preserve">
|
||||
<value>Specifies the name of a while into which internal log information is written</value>
|
||||
</data>
|
||||
<data name="LogfileShort" xml:space="preserve">
|
||||
<value>Log internal information</value>
|
||||
</data>
|
||||
<data name="LoglevelLong" xml:space="preserve">
|
||||
<value>Specifies the amount of log information to write into the file specified by --log-file</value>
|
||||
</data>
|
||||
<data name="LoglevelShort" xml:space="preserve">
|
||||
<value>Log information level</value>
|
||||
</data>
|
||||
</root>
|
||||
Reference in New Issue
Block a user