electron / windows-installer

Build Windows Installers for Electron apps
MIT License
1.58k stars 261 forks source link

Can't catch all the squirrel events in logs #134

Closed junjunruan closed 8 years ago

junjunruan commented 8 years ago

Hi,

I have handled squirrel events in my code (copy from https://github.com/electron/windows-installer), and in each squirrel event, I write some info to the a log file. Below is part of the code:

 fs.writeFileSync("logs.txt", "Installation logs:")
   ...
  const squirrelEvent = process.argv[1];
  switch (squirrelEvent) {
    case '--squirrel-install':
        fs.appendFileSync("logs.txt", "--squirrel-install");

    case '--squirrel-updated':
         ...
        spawnUpdate(['--createShortcut', exeName]);
        fs.appendFileSync("logs.txt", "--squirrel-updated");
        setTimeout(app.quit, 1000);
        return true;

    case '--squirrel-uninstall':
        fs.appendFileSync("logs.txt", "--squirrel-uninstall");
        setTimeout(app.quit, 1000);
        return true;
  }

After install/uninstall the app, I can only see logs like this, which only include uninstall event: Installation logs:--squirrel-uninstall

When look into SquirrelSetup.log, I can only see info releated to create shortcut. Program: Starting Squirrel Updater: --createShortcut=app.exe

My questions are:

  1. How to catch all the squirrel events, and write them into logs;
  2. questions about SquirrelSetup.log:   1) How SquirrelSetup.log is created?   2) What kind of info will go into this file?   3) Is it possible to catch all the squirrel events and write them to SquirrelSetup.log?
MarshallOfSound commented 8 years ago

1) How SquirrelSetup.log is created?

Squirrel.Windows creates the log when Update.exe is spawned with arguments

2) What kind of info will go into this file?

Squirrel.Windows logs a lot of things to this file. Installation progress (copying files), install errors (Access Denied and other such errors), and update requests / response data.

3) Is it possible to catch all the squirrel events and write them to SquirrelSetup.log?

I'm interpreting this as "can I write custom logs to the SquirrelSetup log file". I believe the answer is no.

junjunruan commented 8 years ago

Hi @MarshallOfSound,

Thanks for your reply.

For question 2), I only see create shortcut logs, and didn't see other info that you mentioned above. Do you know why?

Here is my SquirrelSetup.log:

2016-08-30 10:46:48> Program: Starting Squirrel Updater: --createShortcut app.exe
2016-08-30 10:46:48> ApplyReleasesImpl: About to create shortcuts for app.exe, rootAppDir C:\Users\xx\AppData\Local\app
2016-08-30 10:46:48> ApplyReleasesImpl: Creating shortcut for app.exe => C:\Users\xx\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\GitHub, Inc.\app.lnk
2016-08-30 10:46:48> ApplyReleasesImpl: About to save shortcut: C:\Users\xx\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\GitHub, Inc.\app.lnk (target C:\Users\xx\AppData\Local\app\Update.exe, workingDir C:\Users\xx\AppData\Local\app\app-5.0.0, args --processStart "app.exe")
2016-08-30 10:46:48> ApplyReleasesImpl: Creating shortcut for app.exe => C:\Users\xx\Desktop\app.lnk
2016-08-30 10:46:48> ApplyReleasesImpl: About to save shortcut: C:\Users\xx\Desktop\app.lnk (target C:\Users\xx\AppData\Local\app\Update.exe, workingDir C:\Users\xx\AppData\Local\app\app, args --processStart "app.exe")

For question 3), if custom logs can't written to the SquirrelSetup log file, is there any way to write it to a new file? From the example code above, I have code to write logs to log.txt file during each squirrel event. However, I can only see logs for --squirrel-uninstall event, it just ignores fs write file function inside other events. Do you know why?

MarshallOfSound commented 8 years ago

As a sample extract from one of my Squirrel log files.

2016-08-20 04:28:52> Program: Starting Squirrel Updater: --download https://update.gpmdp.xyz/update/win/3.4.3
2016-08-20 04:28:52> Program: Fetching update information, downloading from https://update.gpmdp.xyz/update/win/3.4.3
2016-08-20 04:28:52> CheckForUpdateImpl: Downloading RELEASES file from https://update.gpmdp.xyz/update/win/3.4.3
2016-08-20 04:28:52> FileDownloader: Downloading url: https://update.gpmdp.xyz/update/win/3.4.3/RELEASES?id=GPMDP_3&localVersion=3.4.3&arch=amd64
2016-08-20 04:28:53> FileDownloader: Downloading file: http://update.gpmdp.xyz/download/3.5.0/GPMDP_3-3.5.0-delta.nupkg
2016-08-20 04:29:08> UpdateInfo: Couldn't get release notes for:GPMDP_3-3.5.0-delta.nupkg: System.Exception: Invalid 'ReleaseNotes' value in nuspec file at 'C:\Users\username\AppData\Local\GPMDP_3\packages\GPMDP_3-3.5.0-delta.nupkg'
   at Squirrel.ReleaseEntry.GetReleaseNotes(String packageDirectory)
   at Squirrel.UpdateInfo.<FetchReleaseNotes>b__2(ReleaseEntry x)
2016-08-20 04:29:08> Program: Starting Squirrel Updater: --update https://update.gpmdp.xyz/update/win/3.4.3
2016-08-20 04:29:08> Program: Starting update, downloading from https://update.gpmdp.xyz/update/win/3.4.3
2016-08-20 04:29:08> Program: About to update to: C:\Users\username\AppData\Local\GPMDP_3
2016-08-20 04:29:08> CheckForUpdateImpl: Downloading RELEASES file from https://update.gpmdp.xyz/update/win/3.4.3
2016-08-20 04:29:08> FileDownloader: Downloading url: https://update.gpmdp.xyz/update/win/3.4.3/RELEASES?id=GPMDP_3&localVersion=3.4.3&arch=amd64
2016-08-20 04:29:09> FileDownloader: Downloading file: http://update.gpmdp.xyz/download/3.5.0/GPMDP_3-3.5.0-delta.nupkg
2016-08-20 04:30:01> DeltaPackageBuilder: Adding new file: lib\net45\blink_image_resources_200_percent.pak
2016-08-20 04:30:01> DeltaPackageBuilder: lib\net45\content_resources_200_percent.pak.diff exists unchanged, skipping
2016-08-20 04:30:01> DeltaPackageBuilder: Applying MSDiff to lib\net45\content_shell.pak.diff
2016-08-20 04:30:03> Program: Failed to apply updates, falling back to full updates: System.ComponentModel.Win32Exception (0x80004005): The system cannot find the file specified
   at DeltaCompressionDotNet.MsDelta.MsDeltaCompression.ApplyDelta(String deltaFilePath, String oldFilePath, String newFilePath)
   at Squirrel.DeltaPackageBuilder.applyDiffToFile(String deltaPath, String relativeFilePath, String workingDirectory)
   at Squirrel.DeltaPackageBuilder.<>c__DisplayClass1c.<ApplyDeltaPackage>b__d(String file)
   at Squirrel.EnumerableExtensions.ForEach[TSource](IEnumerable`1 source, Action`1 onNext)
   at Squirrel.DeltaPackageBuilder.ApplyDeltaPackage(ReleasePackage basePackage, ReleasePackage deltaPackage, String outputFile)
   at Squirrel.UpdateManager.ApplyReleasesImpl.<>c__DisplayClassca.<createFullPackagesFromDeltas>b__c6()
   at System.Threading.Tasks.Task`1.InnerInvoke()
   at System.Threading.Tasks.Task.Execute()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Squirrel.UpdateManager.ApplyReleasesImpl.<createFullPackagesFromDeltas>d__cc.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
   at Squirrel.UpdateManager.ApplyReleasesImpl.<ApplyReleases>d__7a.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Squirrel.UpdateManager.<ApplyReleases>d__a.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
   at Squirrel.Update.Program.<Update>d__48.MoveNext()
2016-08-20 04:30:03> CheckForUpdateImpl: Downloading RELEASES file from https://update.gpmdp.xyz/update/win/3.4.3
2016-08-20 04:30:03> FileDownloader: Downloading url: https://update.gpmdp.xyz/update/win/3.4.3/RELEASES?id=GPMDP_3&localVersion=3.4.3&arch=amd64
2016-08-20 04:30:04> FileDownloader: Downloading file: http://update.gpmdp.xyz/download/3.5.0/GPMDP_3-3.5.0-full.nupkg
2016-08-20 04:30:29> ApplyReleasesImpl: Writing files to app directory: C:\Users\username\AppData\Local\GPMDP_3\app-3.5.0
2016-08-20 04:30:57> ApplyReleasesImpl: Moving file C:\Users\username\AppData\Local\GPMDP_3\app-3.5.0\lib\net45\d3dcompiler_47.dll to C:\Users\username\AppData\Local\GPMDP_3\app-3.5.0\d3dcompiler_47.dll
2016-08-20 04:30:57> ApplyReleasesImpl: Moving file C:\Users\username\AppData\Local\GPMDP_3\app-3.5.0\lib\net45\blink_image_resources_200_percent.pak to C:\Users\username\AppData\Local\GPMDP_3\app-3.5.0\blink_image_resources_200_percent.pak
2016-08-20 04:30:57> ApplyReleasesImpl: Moving file C:\Users\username\AppData\Local\GPMDP_3\app-3.5.0\lib\net45\content_shell.pak to C:\Users\username\AppData\Local\GPMDP_3\app-3.5.0\content_shell.pak
2016-08-20 04:30:57> ApplyReleasesImpl: Moving file C:\Users\username\AppData\Local\GPMDP_3\app-3.5.0\lib\net45\content_resources_200_percent.pak to C:\Users\username\AppData\Local\GPMDP_3\app-3.5.0\content_resources_200_percent.pak
2016-08-20 04:30:57> ApplyReleasesImpl: Moving file C:\Users\username\AppData\Local\GPMDP_3\app-3.5.0\lib\net45\ffmpeg.dll to C:\Users\username\AppData\Local\GPMDP_3\app-3.5.0\ffmpeg.dll
2016-08-20 04:30:57> ApplyReleasesImpl: Moving file C:\Users\username\AppData\Local\GPMDP_3\app-3.5.0\lib\net45\Google%20Play%20Music%20Desktop%20Player.exe to C:\Users\username\AppData\Local\GPMDP_3\app-3.5.0\Google%20Play%20Music%20Desktop%20Player.exe
2016-08-20 04:30:57> ApplyReleasesImpl: Moving file C:\Users\username\AppData\Local\GPMDP_3\app-3.5.0\lib\net45\icudtl.dat to C:\Users\username\AppData\Local\GPMDP_3\app-3.5.0\icudtl.dat
2016-08-20 04:30:57> ApplyReleasesImpl: Moving file C:\Users\username\AppData\Local\GPMDP_3\app-3.5.0\lib\net45\libEGL.dll to C:\Users\username\AppData\Local\GPMDP_3\app-3.5.0\libEGL.dll
2016-08-20 04:30:57> ApplyReleasesImpl: Moving file C:\Users\username\AppData\Local\GPMDP_3\app-3.5.0\lib\net45\libGLESv2.dll to C:\Users\username\AppData\Local\GPMDP_3\app-3.5.0\libGLESv2.dll
2016-08-20 04:30:57> ApplyReleasesImpl: Moving file C:\Users\username\AppData\Local\GPMDP_3\app-3.5.0\lib\net45\LICENSE to C:\Users\username\AppData\Local\GPMDP_3\app-3.5.0\LICENSE
2016-08-20 04:30:57> ApplyReleasesImpl: Moving file C:\Users\username\AppData\Local\GPMDP_3\app-3.5.0\lib\net45\natives_blob.bin to C:\Users\username\AppData\Local\GPMDP_3\app-3.5.0\natives_blob.bin
2016-08-20 04:30:57> ApplyReleasesImpl: Moving file C:\Users\username\AppData\Local\GPMDP_3\app-3.5.0\lib\net45\node.dll to C:\Users\username\AppData\Local\GPMDP_3\app-3.5.0\node.dll
2016-08-20 04:30:57> ApplyReleasesImpl: Moving file C:\Users\username\AppData\Local\GPMDP_3\app-3.5.0\lib\net45\squirrel.exe to C:\Users\username\AppData\Local\GPMDP_3\app-3.5.0\squirrel.exe
2016-08-20 04:30:57> ApplyReleasesImpl: Moving file C:\Users\username\AppData\Local\GPMDP_3\app-3.5.0\lib\net45\ui_resources_200_percent.pak to C:\Users\username\AppData\Local\GPMDP_3\app-3.5.0\ui_resources_200_percent.pak
2016-08-20 04:30:57> ApplyReleasesImpl: Moving file C:\Users\username\AppData\Local\GPMDP_3\app-3.5.0\lib\net45\xinput1_3.dll to C:\Users\username\AppData\Local\GPMDP_3\app-3.5.0\xinput1_3.dll
2016-08-20 04:30:57> ApplyReleasesImpl: Moving file C:\Users\username\AppData\Local\GPMDP_3\app-3.5.0\lib\net45\snapshot_blob.bin to C:\Users\username\AppData\Local\GPMDP_3\app-3.5.0\snapshot_blob.bin
2016-08-20 04:30:57> ApplyReleasesImpl: Moving file C:\Users\username\AppData\Local\GPMDP_3\app-3.5.0\lib\net45\views_resources_200_percent.pak to C:\Users\username\AppData\Local\GPMDP_3\app-3.5.0\views_resources_200_percent.pak
2016-08-20 04:30:57> ApplyReleasesImpl: Squirrel Enabled Apps: [C:\Users\username\AppData\Local\GPMDP_3\app-3.5.0\Google%20Play%20Music%20Desktop%20Player.exe]
2016-08-20 04:30:58> ApplyReleasesImpl: Starting fixPinnedExecutables
2016-08-20 04:30:58> ApplyReleasesImpl: Examining Pin: Android Studio.lnk
2016-08-20 04:30:58> ApplyReleasesImpl: Examining Pin: babun.lnk
2016-08-20 04:30:58> ApplyReleasesImpl: Examining Pin: Bash on Ubuntu on Windows.lnk
2016-08-20 04:30:58> ApplyReleasesImpl: Examining Pin: File Explorer.lnk
2016-08-20 04:30:58> ApplyReleasesImpl: Examining Pin: Flash Maths SSH.lnk

This extract shows an example of moving file logs, error logs and other logs (like pin fixes)

Yes, you can log to a new file, personally I use Winston to do that for me and I don't have time to check your JS syntax right now 👍 . But it will work if you use the right methods. Make sure you are using the syncronous variants 👍

eminoda commented 7 years ago

How can i setting the 'squirrel.log' dirtectory? if user install the application in the Program FIles , the application'access is not good when updating.