Squirrel.Update.SetupLogLogger.Write C# (CSharp) Method

Write() public method

public Write ( string message, LogLevel logLevel ) : void
message string
logLevel LogLevel
return void
        public void Write(string message, LogLevel logLevel)
        {
            if (logLevel < Level) {
                return;
            }

            lock (gate)
            {
                inner.WriteLine("{0}> {1}", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), message);
                inner.Flush();
            }
        }

Usage Example

Example #1
0
        int main(string[] args)
        {
            // NB: Trying to delete the app directory while we have Setup.log
            // open will actually crash the uninstaller
            bool isUninstalling = args.Any(x => x.Contains("uninstall"));

            // Uncomment to test Gifs
            //AnimatedGifWindow.ShowWindow(TimeSpan.FromMilliseconds(0), animatedGifWindowToken.Token);
            //Thread.Sleep(10 * 60 * 1000);

            using (var logger = new SetupLogLogger(isUninstalling)
            {
                Level = LogLevel.Info
            })
            {
                Locator.CurrentMutable.Register(() => logger, typeof(Splat.ILogger));
                try
                {
                    return(executeCommandLine(args));
                }
                catch (Exception ex)
                {
                    logger.Write("Unhandled exception: " + ex, LogLevel.Fatal);
                    throw;
                }
                // Ideally we would deregister the logger from the Locator before it was disposed - this is a hazard as it is at the moment
            }
        }
All Usage Examples Of Squirrel.Update.SetupLogLogger::Write