Squirrel.Windows
Squirrel.Windows copied to clipboard
How to set SquirrelSetup.log directory with Squirrel 1.7.5?
Hello,
I am using Squirrel 1.7.5 and I want to set the SquirrelSetup.log file directoy. Is that possible? If not, is there any other way to accomplish that?
The problem is that I have other applications that use Squirrel as their update mechanism and I have information about all those applications in the %APPDATA%\Local\SquirrelTemp\SquirrelSetup.log. What I want to accomplish is having a separate Squirrel.log file inside the application that uses Squirrel that contains logs ONLY for this application so that I can handle any issues. I also don't have any SquirrelSetup.log file inside the %APPDATA%\Local\MyApp folder. What can I do?
Thanks.
Squirrel only logs to %localappdata%\SquirrelTemp\SquirrelSetup.log on initial install. If you manually call Update.exe via the command line it will create a SquirrelSetup.log for the update in the same directory as the executable (as long as you don't set the --uninstall flag).
When you use the UpdateManager it doesn't have a logger setup by default. I'm not positive but I believe you can hook one up by first configuring and registering a Splat logger in your class that calls UpdateManager. The UpdateManager will then use it. In order to do this you'll need to implement your own SetupLogLogger class similar to how the Update.exe does, see https://github.com/Squirrel/Squirrel.Windows/blob/2932c8db7394a7bba1cfa56c10fc7d4ab46b3c79/src/Update/Program.cs#L846.
Then you'll need to register an instance of the SetupLogLogger with Splat in your class constructor similar to https://github.com/Squirrel/Squirrel.Windows/blob/2932c8db7394a7bba1cfa56c10fc7d4ab46b3c79/src/Update/Program.cs#L47
@SissiKonsta did @Logikgate answered your question? If so, you can close this issue.
I cannot make update manager work logging work using the above or suggestions here: https://github.com/Squirrel/Squirrel.Windows/blob/develop/docs/using/debugging-updates.md Without logging it's virtually impossible to diagnose an issue. Update just hangs and that's it. Any help would be appreciated.
If you are using Update.exe via command line, it will write a log to the current working directory. Doing this is a great way to diagnose issues quickly.
If you need to log from within your own application (eg. using UpdateManager directly) then you will need to wire up the logging yourself. You can take this ConsoleLogger.cs as an example, the key is in Register() where you call SquirrelLocator.CurrentMutable.Register. You can use this method to log to console, to a file, etc within your own application.
Thanks for the quick reply! In my own class, Is implementing Squirrel.SimpleSplat.ILogger enough? Do I have to implement implement the whole IFullLogger used by the manager?
Implementing ILogger is enough. Then register your class via SquirrelLocator.CurrentMutable.Register and you're all set.
Yup, I made the logging work thanks to you! However it didn't help me as nothing is logged. It seems like it gets stock on the last return in the below code in the update manager:
Task<IDisposable> acquireUpdateLock()
{
if (updateLock != null) return Task.FromResult(updateLock);
return Task.Run(() => {
var key = Utility.CalculateStreamSHA1(new MemoryStream(Encoding.UTF8.GetBytes(rootAppDirectory)));
IDisposable theLock;
try {
theLock = ModeDetector.InUnitTestRunner() ?
Disposable.Create(() => {}) : new SingleGlobalInstance(key, TimeSpan.FromMilliseconds(2000));
} catch (TimeoutException) {
throw new TimeoutException("Couldn't acquire update lock, another instance may be running updates");
}
var ret = Disposable.Create(() => {
theLock.Dispose();
updateLock = null;
});
updateLock = ret;
return ret;
});
}