/// <summary> /// Registers a trace listener. /// </summary> /// <param name="listener"></param> public static void RegisterListener(TraceListener listener) { if (_loggingEnabled) { _source.Listeners.Add(listener); } }
public HttpQueryableServiceSpec() { this.listener = new ConsoleTraceListener(); this.listener.Name = Guid.NewGuid().ToString(); TracerExtensibility.AddListener(SourceName.For<TracingChannel>(), listener); TracerExtensibility.SetTracingLevel(SourceName.For<TracingChannel>(), SourceLevels.All); }
public void Write(TraceListener.TraceData value) { if (value.Message != null) { builder.Append(value.Message.Value); } if (value.NewLine != null) { builder.AppendLine(); } }
protected void InstrumentAndAssert(string assemblyPath, string db4oToolOptions, bool shouldContain, params string[] expectedMessages) { TraceListener listener = new TraceListener(); Trace.Listeners.Add(listener); RunDb4oTool(db4oToolOptions, assemblyPath); Trace.Listeners.Remove(listener); Assert.AreEqual(expectedMessages.Length, listener.Contents.Count, Zip(listener.Contents)); foreach (string message in expectedMessages) { Assert.AreEqual(shouldContain, Contains(listener.Contents, message)); } }
public void Tracing() { // Given Engine engine = new Engine(); IExecutionContext context = GetExecutionContext(engine); IDocument document = Substitute.For<IDocument>(); TraceListener traceListener = new TraceListener(); Trace.AddListener(traceListener); document.GetStream().Returns(new MemoryStream(Encoding.UTF8.GetBytes(@"@{ Trace.Information(""Test""); }"))); Razor razor = new Razor(); // When razor.Execute(new[] { document }, context).ToList(); // Make sure to materialize the result list // Then Trace.RemoveListener(traceListener); CollectionAssert.Contains(traceListener.Messages, "Test"); }
public virtual void TestInitialize() { UIThreadInvoker.Initialize(); // Causes devenv to initialize var devEnv = Clide.DevEnv.Get(new Guid(IntegrationPackage.Constants.PackageGuid)); this.tracer = Tracer.Get(this.GetType()); this.strings = new StringBuilder(); this.listener = new TextWriterTraceListener(new StringWriter(this.strings)); // Just in case, re-set the tracers. Tracer.Manager.SetTracingLevel(TracerManager.DefaultSourceName, SourceLevels.All); Tracer.Manager.AddListener(TracerManager.DefaultSourceName, this.listener); tracer.Info("Running test from: " + this.TestContext.TestDeploymentDir); if (Dte != null) { Dte.SuppressUI = false; Dte.MainWindow.Visible = true; Dte.MainWindow.WindowState = EnvDTE.vsWindowState.vsWindowStateNormal; } var shellEvents = new ShellEvents(ServiceProvider); var initialized = shellEvents.IsInitialized; while (!initialized) { System.Threading.Thread.Sleep(10); } tracer.Info("Shell initialized successfully"); if (VsIdeTestHostContext.ServiceProvider == null) VsIdeTestHostContext.ServiceProvider = new VsServiceProvider(); cleanupFolders = new List<string>(); }
/// <summary> /// Derived method to initialize trace listener to write trace data separated by a delimiter /// </summary> /// <param name="traceSource">Trace source that holds a set of handlers</param> /// <param name="filterLevels">The level of trace message filtered by trace listener</param> /// <param name="traceOptions">Trace data options that has to be written in the trace output</param> /// <param name="traceListener">Trace listener object associated with the trace source</param> public override void InitListener(out TraceListener traceListener) { traceListener = new DelimitedListTraceListener(this.GetStreamWriter()); }
public virtual void addTraceListener(TraceListener l) { ((CharScanner)source).EnterRule += new TraceEventHandler(l.enterRule); ((CharScanner)source).ExitRule += new TraceEventHandler(l.exitRule); addDoneListener(l); }
public static async Task <DeletableFileStream> TryGetStreamAsync(string containerName, string fileName, TraceListener log) { var localFileName = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString() + ".tmp"); var cacheFileName = Path.Combine(Path.GetTempPath(), fileName); foreach (DriveInfo d in DriveInfo.GetDrives().Where(p => p.Name.ToLower()[0] == localFileName.ToLower()[0] && p.IsReady)) { log?.WriteLine(string.Format("{0} has {1, 15} bytes available", d.Name, d.AvailableFreeSpace)); } if (!File.Exists(cacheFileName)) { try { CloudBlockBlob blockBlob = (await GetContainerAsync(containerName, log)).GetBlockBlobReference(fileName); await blockBlob.DownloadToFileAsync(localFileName, FileMode.CreateNew); } catch (Exception ex) { log?.WriteLine("Missing blob: " + fileName); log?.WriteLine("Error was:" + ex.ToString()); return(null); } var fi = new FileInfo(localFileName); if (!File.Exists(cacheFileName)) { fi.CopyTo(cacheFileName); } } else { var fi = new FileInfo(cacheFileName); fi.CopyTo(localFileName); } var fs = File.OpenRead(localFileName); fs.Position = 0; var ret = new DeletableFileStream(localFileName, fs); return(ret); }
public static void SetTraceListener(TraceListener listener) { _traceListener = listener; }
public int IndexOf(TraceListener listener);
public virtual void removeTraceListener(TraceListener l) { if (!ignoreInvalidDebugCalls) throw new System.SystemException("removeTraceListener() is only valid if parser built for debugging"); }
/// <summary> /// Derived method to initialize trace listener to write trace data in event viewer /// </summary> /// <param name="traceSource">Trace source that holds a set of handlers</param> /// <param name="filterLevels">The level of trace message filtered by trace listener</param> /// <param name="traceOptions">Trace data options that has to be written in the trace output</param> /// <param name="traceListener">Trace listener object associated with the trace source</param> public override void InitListener(out TraceListener traceListener) { traceListener = new EventLogTraceListener("SiteController"); }
public static async Task SyncFunctionsTriggers(string requestId, TraceListener tracer, string functionsPath = null) { _tracer = tracer; if (string.IsNullOrEmpty(FunctionRunTimeVersion)) { Trace(TraceEventType.Verbose, "Skip function trigger and logicapp sync because function is not enabled."); return; } if (!string.Equals(Constants.DynamicSku, WebSiteSku, StringComparison.OrdinalIgnoreCase)) { Trace(TraceEventType.Verbose, string.Format("Skip function trigger and logicapp sync because sku ({0}) is not dynamic (consumption plan).", WebSiteSku)); return; } VerifyEnvironments(); functionsPath = !string.IsNullOrEmpty(functionsPath) ? functionsPath : System.Environment.ExpandEnvironmentVariables(@"%HOME%\site\wwwroot"); // Read host.json // Get HubName property for Durable Functions string taskHubName = null; string hostJson = Path.Combine(functionsPath, Constants.FunctionsHostConfigFile); if (File.Exists(hostJson)) { taskHubName = GetTaskHub(hostJson); } // Collect each functions.json var triggers = Directory .GetDirectories(functionsPath) .Select(d => Path.Combine(d, Constants.FunctionsConfigFile)) .Where(File.Exists) .SelectMany(f => DeserializeFunctionTrigger(f)) .ToList(); if (File.Exists(Path.Combine(functionsPath, Constants.ProxyConfigFile))) { var routing = new JObject(); routing["type"] = "routingTrigger"; triggers.Add(routing); } // Add hubName to each Durable Functions trigger if (!string.IsNullOrEmpty(taskHubName)) { foreach (var trigger in triggers) { JToken typeValue; if (trigger.TryGetValue("type", out typeValue) && typeValue != null && (typeValue.ToString().Equals("orchestrationTrigger", StringComparison.OrdinalIgnoreCase) || typeValue.ToString().Equals("activityTrigger", StringComparison.OrdinalIgnoreCase))) { trigger["taskHubName"] = taskHubName; } } } var content = JsonConvert.SerializeObject(triggers); Exception exception = null; try { await PostAsync("/operations/settriggers", requestId, content); } catch (Exception ex) { exception = ex; throw; } finally { Trace(TraceEventType.Information, "Syncing {0} function triggers with payload size {1} bytes {2}", triggers.Count, content.Length, exception == null ? "successful." : ("failed with " + exception)); } // this couples with sync function triggers await SyncLogicAppJson(requestId, tracer); }
public FileLogging(string path, string instance) { listener = new TextWriterTraceListener(path, instance); }
/// <summary> /// Main method. /// </summary> /// <param name="Arguments">Command line</param> public static ExitCode Process(string[] Arguments, StartupTraceListener StartupListener) { // Initial check for local or build machine runs BEFORE we parse the command line (We need this value set // in case something throws the exception while parsing the command line) IsBuildMachine = !String.IsNullOrEmpty(Environment.GetEnvironmentVariable("uebp_LOCAL_ROOT")) || Arguments.Any(x => x.Equals("-BuildMachine", StringComparison.InvariantCultureIgnoreCase)); // Scan the command line for commands to execute. var CommandsToExecute = new List <CommandInfo>(); string OutScriptsForProjectFileName; var AdditionalScriptsFolders = new List <string>(); ParseCommandLine(Arguments, CommandsToExecute, out OutScriptsForProjectFileName, AdditionalScriptsFolders); // Get the path to the telemetry file, if present string TelemetryFile = CommandUtils.ParseParamValue(Arguments, "-Telemetry"); Log.TraceVerbose("IsBuildMachine={0}", IsBuildMachine); Environment.SetEnvironmentVariable("IsBuildMachine", IsBuildMachine ? "1" : "0"); // should we kill processes on exit ShouldKillProcesses = !GlobalCommandLine.NoKill; Log.TraceVerbose("ShouldKillProcesses={0}", ShouldKillProcesses); if (CommandsToExecute.Count == 0 && GlobalCommandLine.Help) { DisplayHelp(); return(ExitCode.Success); } // Disable AutoSDKs if specified on the command line if (GlobalCommandLine.NoAutoSDK) { PlatformExports.PreventAutoSDKSwitching(); } // Setup environment Log.TraceLog("Setting up command environment."); CommandUtils.InitCommandEnvironment(); // Determine if the engine is installed bIsEngineInstalled = GlobalCommandLine.Installed; string InstalledBuildFile = Path.Combine(CommandUtils.CmdEnv.LocalRoot, "Engine", "Build", "InstalledBuild.txt"); bIsEngineInstalled |= File.Exists(InstalledBuildFile); if (bIsEngineInstalled.Value) { bIsEngineInstalled = !GlobalCommandLine.NotInstalledEngine; } else { bIsEngineInstalled = GlobalCommandLine.InstalledEngine; } // Create the log file, and flush the startup listener to it TraceListener LogTraceListener = LogUtils.AddLogFileListener(CommandUtils.CmdEnv.LogFolder, CommandUtils.CmdEnv.FinalLogFolder); StartupListener.CopyTo(LogTraceListener); Trace.Listeners.Remove(StartupListener); // Initialize UBT if (!UnrealBuildTool.PlatformExports.Initialize(bIsEngineInstalled.Value)) { Log.TraceInformation("Failed to initialize UBT"); return(ExitCode.Error_Unknown); } // Fill in the project info UnrealBuildTool.UProjectInfo.FillProjectInfo(); // Clean rules folders up ProjectUtils.CleanupFolders(); // Compile scripts. ScriptCompiler Compiler = new ScriptCompiler(); using (TelemetryStopwatch ScriptCompileStopwatch = new TelemetryStopwatch("ScriptCompile")) { Compiler.FindAndCompileAllScripts(OutScriptsForProjectFileName, AdditionalScriptsFolders); } if (GlobalCommandLine.CompileOnly) { Log.TraceInformation("Compilation successful, exiting (CompileOnly)"); return(ExitCode.Success); } if (GlobalCommandLine.List) { ListAvailableCommands(Compiler.Commands); return(ExitCode.Success); } if (GlobalCommandLine.Help) { DisplayHelp(CommandsToExecute, Compiler.Commands); return(ExitCode.Success); } // Enable or disable P4 support CommandUtils.InitP4Support(CommandsToExecute, Compiler.Commands); if (CommandUtils.P4Enabled) { Log.TraceLog("Setting up Perforce environment."); CommandUtils.InitP4Environment(); CommandUtils.InitDefaultP4Connection(); } // Find and execute commands. ExitCode Result = Execute(CommandsToExecute, Compiler.Commands); if (TelemetryFile != null) { Directory.CreateDirectory(Path.GetDirectoryName(TelemetryFile)); CommandUtils.Telemetry.Write(TelemetryFile); } return(Result); }
public FileLogging() { listener = new TextWriterTraceListener("logs.txt", "TpaLogs"); }
public static async Task Run(string requestId, string siteRestrictedJwt, TraceListener tracer) { await Invoke(requestId, tracer); }
public static async Task SyncLogicAppJson(string requestId, TraceListener tracer) { _tracer = tracer; var logicAppUrl = LogicAppUrl; if (string.IsNullOrEmpty(logicAppUrl)) { return; } var fileInfo = new FileInfo(LogicAppJsonFilePath); if (!fileInfo.Exists) { Trace(TraceEventType.Verbose, "File {0} does not exists", fileInfo.FullName); return; } var displayUrl = logicAppUrl; var queryIndex = logicAppUrl.IndexOf('?'); if (queryIndex > 0) { // for display/logging, strip out querystring secret displayUrl = logicAppUrl.Substring(0, queryIndex); } var content = File.ReadAllText(fileInfo.FullName); var statusCode = default(HttpStatusCode); Exception exception = null; try { Trace(TraceEventType.Verbose, "Begin HttpPut {0}, x-ms-client-request-id: {1}", displayUrl, requestId); using (var client = HttpClientFactory()) { client.DefaultRequestHeaders.UserAgent.Add(_userAgent.Value); client.DefaultRequestHeaders.Add(Constants.ClientRequestIdHeader, requestId); var payload = new StringContent(content ?? string.Empty, Encoding.UTF8, "application/json"); using (var response = await client.PutAsync(logicAppUrl, payload)) { statusCode = response.StatusCode; response.EnsureSuccessStatusCode(); } } } catch (Exception ex) { exception = ex; throw; } finally { Trace(TraceEventType.Verbose, "End HttpPut, status: {0}", statusCode); Trace(TraceEventType.Information, "Syncing logicapp {0} with payload size {1} bytes {2}", displayUrl, content.Length, exception == null ? "successful." : ("failed with " + exception)); } }
/// <summary> /// Remove the specified TraceListener from the collection /// </summary> /// <param name="listener">The TraceListener to remove from the collection.</param> public static void RemoveListener(TraceListener listener) { lock (m_listeners) { m_listeners.Remove(listener); } }
public void RenderChunksInto(IEnumerable <ChunkHolder <T> > chunks, Func <int, T, T, T> aggregate, TraceListener log) { double[] buffer = new double[toDouble.Length]; int[][] counter = new int[this.LatSteps][]; for (int i = 0; i < this.LatSteps; i++) { counter[i] = new int[this.LonSteps]; } foreach (var loopChunk in chunks.Where(p => p != null)) { log?.WriteLine("Processing " + loopChunk); InterpolatingChunk <T> chunk2 = null; if (loopChunk.PixelSizeLatDeg > this.PixelSizeLatDeg || loopChunk.PixelSizeLonDeg > this.PixelSizeLonDeg) { // Need to interpolate. chunk2 = loopChunk.ComputeInterpolation(this.LatLo, this.LonLo, this.LatHi, this.LonHi, this.toDouble, this.fromDouble, InterpolatonType.Cubic); } for (int i = 0; i < this.LatSteps; i++) { Angle loopLat = this.GetLat(i); if (chunk2 == null) { if (!loopChunk.HasDataAtLat(loopLat)) { continue; } } else { if (!chunk2.HasDataAtLat(loopLat.DecimalDegree)) { continue; } } for (int j = 0; j < this.LonSteps; j++) { Angle loopLon = this.GetLon(j); if (chunk2 == null) { if (loopChunk.TryGetDataAtPoint(loopLat, loopLon, out T data)) { this.Data[i][j] = aggregate(counter[i][j], this.Data[i][j], data); counter[i][j]++; } else { } } else { if (chunk2.TryGetDataAtPoint(loopLat.DecimalDegree, loopLon.DecimalDegree, buffer, out T data)) { this.Data[i][j] = aggregate(counter[i][j], this.Data[i][j], data); counter[i][j]++; } else { } } } } } bool missingArea = false; for (int i = 0; i < counter.Length; i++) { for (int j = 0; j < counter[i].Length; j++) { if (counter[i][j] == 0) { missingArea = true; // throw new InvalidOperationException("The chunks do not cover the area of this chunk: " + this.ToString()); } } } if (missingArea) { log?.WriteLine("The chunks do not cover the area of this chunk: " + this.ToString()); } }
public virtual void addTraceListener(TraceListener l) { eventSupport.addTraceListener(l); }
private static void AddListenerToSources(Collection <PSTraceSource> matchingSources, TraceListener listener) { // Now add the listener to all the sources foreach (PSTraceSource source in matchingSources) { source.Listeners.Add(listener); } }
public bool Contains(TraceListener listener);
public async Task <NearestInterpolatingChunk <T> > GetLazySimpleInterpolator(StandardChunkMetadata template, TraceListener log) { if (template == null) { return(null); } string filename = GetShortFilename(template); string fullFileName = GetFullFileName(template, filename); while ( !(await BlobHelper.BlobExists(cachedFileContainer, fullFileName, log)) && template.ZoomLevel > SourceDataZoom) { template = template.GetParentChunk(); return(await GetLazySimpleInterpolator(template, log)); } byte[] buffer = new byte[Math.Max(4, pixelDataSize)]; return(new NearestInterpolatingChunk <T>( template.LatLo.DecimalDegree, template.LonLo.DecimalDegree, template.LatHi.DecimalDegree, template.LonHi.DecimalDegree, template.LatSteps, template.LonSteps, cachedFileContainer, fullFileName, (ms, i, j) => { ms.Seek(8 + pixelDataSize * (i * template.LatSteps + j), SeekOrigin.Begin); return ReadPixel(ms, buffer); })); }
public void Remove(TraceListener listener);
private async Task <Tuple <string, ChunkHolder <T> > > GetComputedChunk(StandardChunkMetadata template, TraceListener log) { string filename = GetShortFilename(template); Tuple <string, ChunkHolder <T> > ret = new Tuple <string, ChunkHolder <T> >(GetFullFileName(template, filename), null); using (var ms = await BlobHelper.TryGetStreamAsync(cachedFileContainer, ret.Item1, log)) { if (ms != null) { ret = new Tuple <string, ChunkHolder <T> >(ret.Item1, ReadChunk(ms, template)); } } return(ret); }
public static async Task <IEnumerable <string> > GetFiles(string containerName, string directory, TraceListener log) { List <string> ret = new List <string>(); var dir = (await GetContainerAsync(containerName, log)).GetDirectoryReference(directory); BlobContinuationToken bcc = null; while (true) { var blobList = await dir.ListBlobsSegmentedAsync( useFlatBlobListing : true, blobListingDetails : BlobListingDetails.None, maxResults : int.MaxValue, currentToken : bcc, options : null, operationContext : null); bcc = blobList.ContinuationToken; ret.AddRange(blobList.Results.OfType <CloudBlockBlob>().Select(p => p.Name)); if (bcc == null) { break; } } return(ret); }
public async Task <bool> ExistsComputedChunk(StandardChunkMetadata template, TraceListener log) { string filename = GetShortFilename(template); return(await BlobHelper.BlobExists(cachedFileContainer, GetFullFileName(template, filename), log)); }
// TODO: Figure out why this was failing to compiile public static async Task <IEnumerable <string> > GetFileNames(string containerName, string prefix, TraceListener log) { var container = await GetContainerAsync(containerName, log); List <IListBlobItem> files = new List <IListBlobItem>(); BlobContinuationToken token = null; do { var segment = await container.ListBlobsSegmentedAsync(prefix, token); files.AddRange(segment.Results); token = segment.ContinuationToken; } while (token != null); return(files .Select(p => p.Uri.ToString()) .Select(p => { var i = p.IndexOf("blob.core.windows.net/"); return p.Substring(i + 22 + containerName.Length + 1); }) .ToArray()); }
protected abstract Task <ChunkHolder <T> > GenerateData(StandardChunkMetadata template, TraceListener log);
public AssertListenerInitializer(TraceListener listener) { _listener = listener; }
public Logger() { _eztextingLogFile = _traceSource.Listeners[ClientConstants.LogFileListenerName]; _serializer = new JsonSerializer(); }
/// <summary> /// Initializes the specified is webservice. /// </summary> /// <param name="isWebservice">if set to <c>true</c> [is webservice].</param> /// <returns></returns> /// <exception cref="System.Exception"> /// Could not initialize ConfigurationManager! /// or /// Could not initialize PropertyManager! /// or /// Could not initialize PluginManager! /// or /// Could not initialize DisplayManager! /// or /// Could not initialize DataStorageManager! /// </exception> public static bool Initialize(bool isWebservice) { bool result = false; try { BaseManager.IsWebservice = isWebservice; //Environment.SetEnvironmentVariable("PATH", Environment.GetEnvironmentVariable("PATH") + ";" + BaseManager.AssemblyPath + Path.DirectorySeparatorChar + "Libs"); AppDomain.CurrentDomain.AssemblyResolve += delegate(object sender, ResolveEventArgs args) { // Find name (first argument) string assemblyName = args.Name.Substring(0, args.Name.IndexOf(',')); try { // Build the path to DLL and load it // WARNING: The path has to be absolute otherwise it will raise an ArgumentException (security) string libsPath = BaseManager.AssemblyPath + Path.DirectorySeparatorChar + "Libs" + Path.DirectorySeparatorChar + assemblyName + ".dll"; string basePath = BaseManager.AssemblyPath + Path.DirectorySeparatorChar + assemblyName + ".dll"; if (File.Exists(libsPath)) return Assembly.LoadFile(libsPath); else if (File.Exists(basePath)) return Assembly.LoadFile(basePath); else return null; } catch (Exception ex) { Trace.WriteLine(ex.Message, ex.StackTrace, LogCategory.Error); throw ex; } }; _traceListener = new TraceListener(BaseManager.LogPath, BaseManager.DaysToKeepLogFiles); _traceListener.SetLoggingCategoties(new List<string> { #if DEBUG LogCategory.Debug.GetDescription(), #endif LogCategory.Info.GetDescription(), LogCategory.Warning.GetDescription(), LogCategory.Error.GetDescription() }); System.Diagnostics.Trace.Listeners.Add(_traceListener); Trace.WriteLine("Initialize CoreSystem ...", LogCategory.Info); _managers.Clear(); // Default managers must be added to the CoreSystem. ProjectManager projectManager = new ProjectManager(); PropertyManager propertyManager = new PropertyManager(); PluginManager pluginManager = new PluginManager(); DisplayManager displayManager = new DisplayManager(); DataStorageManager dataStorageManager = new DataStorageManager(); _managers.Add(projectManager); _managers.Add(propertyManager); _managers.Add(pluginManager); _managers.Add(displayManager); _managers.Add(dataStorageManager); AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve); if (pluginManager.Initialize() == false) throw new Exception("Could not initialize PluginManager!"); if (propertyManager.Initialize() == false) throw new Exception("Could not initialize PropertyManager!"); if (projectManager.Initialize() == false) throw new Exception("Could not initialize ConfigurationManager!"); _traceListener.SetLoggingCategoties(projectManager.Configuration.LogConfiguration.Categories); if (displayManager.Initialize() == false) throw new Exception("Could not initialize DisplayManager!"); if (dataStorageManager.Initialize() == false) throw new Exception("Could not initialize DataStorageManager!"); ExtensionManager extensionManager = CoreSystem.Managers.Find(m => m.Name.Contains("ExtensionManager")) as ExtensionManager; if (extensionManager.Initialize() == false) throw new Exception("Could not initialize ExtensionManager!"); _processor = new Core.Processor(); _shell = new Core.Shell(); _shell.Initialize(); result = true; } catch (Exception ex) { Trace.WriteLine(ex.Message, ex.StackTrace, LogCategory.Error); throw ex; } return result; }
public override void removeTraceListener(TraceListener l) { parserEventSupport.removeTraceListener(l); }
public virtual void removeTraceListener(TraceListener l) { ((CharScanner)source).EnterRule -= new TraceEventHandler(l.enterRule); ((CharScanner)source).ExitRule -= new TraceEventHandler(l.exitRule); removeDoneListener(l); }
public virtual void addTraceListener(TraceListener l) { ((Parser)source).EnterRule += new TraceEventHandler(l.enterRule); ((Parser)source).ExitRule += new TraceEventHandler(l.exitRule); //traceListeners.Add(l); addDoneListener(l); }
public virtual void removeTraceListener(TraceListener l) { eventSupport.removeTraceListener(l); }
public int Add(TraceListener listener);
public async Task <ChunkHolder <T> > ProcessRawData(StandardChunkMetadata template, TraceListener log) { var computedChunk = await GetComputedChunk(template, log); string fileName = computedChunk.Item1; ChunkHolder <T> ret = computedChunk.Item2; if (computedChunk.Item2 != null) { log?.WriteLine("Cached " + description + " chunk file exists: " + fileName); return(computedChunk.Item2); } log?.WriteLine("Cached " + description + " chunk file does not exist: " + fileName); if (template.ZoomLevel > this.SourceDataZoom) { // Nothing to do for processing return(null); } else if (template.ZoomLevel == this.SourceDataZoom) { log?.WriteLine("Starting generation..."); ret = await GenerateData(template, log); await WriteChunk(ret, fileName, log); log?.WriteLine("Finished generation of " + description + " cached chunk file: " + fileName); return(ret); } log?.WriteLine("Need to aggregate up from higher zoom data"); var children = template.GetChildChunks(); List <ChunkHolder <T> > chunks = new List <ChunkHolder <T> >(); foreach (var child in children) { log?.WriteLine(child); chunks.Add(await ProcessRawData(child, log)); } ret = new ChunkHolder <T>( template.LatSteps, template.LonSteps, template.LatLo, template.LonLo, template.LatHi, template.LonHi, null, toDouble, fromDouble); ret.RenderChunksInto(chunks, aggregate, log); await WriteChunk(ret, fileName, log); log?.WriteLine("Finished generation of " + description + " cached chunk file: " + fileName); return(ret); }
public void SetUp() { traceListener = new TraceListener(); Trace.Listeners.Add(traceListener); }
public static async Task Rename(string containerName, string oldName, string newName, TraceListener log) { var container = await GetContainerAsync(containerName, log); var oldBlob = container.GetBlobReference(oldName); var newBlob = container.GetBlobReference(newName); if (await newBlob.ExistsAsync()) { await newBlob.DeleteIfExistsAsync(); } await newBlob.StartCopyAsync(oldBlob.Uri); await oldBlob.DeleteIfExistsAsync(); }
public static async Task <bool> BlobExists(string containerName, string fileName, TraceListener log) { var localFileName = Path.Combine(Path.GetTempPath(), fileName.Replace('/', Path.DirectorySeparatorChar)); if (File.Exists(localFileName)) { return(true); } CloudBlockBlob blockBlob = (await GetContainerAsync(containerName, log)).GetBlockBlobReference(fileName); return(await blockBlob.ExistsAsync()); }
public override void addTraceListener(TraceListener l) { parserEventSupport.addTraceListener(l); }
public static async Task <IEnumerable <string> > ReadAllLines(string containerName, string fileName, TraceListener log) { List <string> ret = new List <string>(); using (var stream = await TryGetStreamAsync(containerName, fileName, log)) { using (var reader = new StreamReader(stream.Stream)) { string line; while ((line = reader.ReadLine()) != null) { ret.Add(line); } } } return(ret); }
public virtual void removeTraceListener(TraceListener l) { ((Parser)source).EnterRule -= new TraceEventHandler(l.enterRule); ((Parser)source).ExitRule -= new TraceEventHandler(l.exitRule); //traceListeners.Remove(l); removeDoneListener(l); }
private static async Task <CloudBlobContainer> GetContainerAsync(string containerName, TraceListener log) { if (!singleton.TryGetValue(containerName, out CloudBlobContainer ret)) { if (string.IsNullOrEmpty(connectionString)) { log?.WriteLine("Must set the 'connectionString' property prior to use"); throw new MountainViewException("Must set the 'connectionString' property prior to use"); } CloudStorageAccount storageAccount = CloudStorageAccount.Parse(connectionString); CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient(); ret = blobClient.GetContainerReference(containerName); await ret.CreateIfNotExistsAsync(); singleton.AddOrUpdate(containerName, ret, (a, b) => b); } return(ret); }
public void AddRange(TraceListener[] value);
public static async Task WriteStream(string containerName, string fileName, MemoryStream stream, TraceListener log) { CloudBlockBlob blockBlob = (await GetContainerAsync(containerName, log)).GetBlockBlobReference(fileName); await blockBlob.UploadFromStreamAsync(stream); }
public void CopyTo(TraceListener[] listeners, int index);
public static async Task <string> WriteStream(string containerName, string fileName, string sourceName, TraceListener log) { CloudBlockBlob blockBlob = (await GetContainerAsync(containerName, log)).GetBlockBlobReference(fileName); await blockBlob.UploadFromFileAsync(sourceName); return(blockBlob.Uri.ToString()); }
public void Insert(int index, TraceListener listener);
public static async Task <IEnumerable <string> > GetDirectories(string containerName, string directoryPrefix, TraceListener log) { var blobList = await(await GetContainerAsync(containerName, log)) .ListBlobsSegmentedAsync(directoryPrefix, false, BlobListingDetails.None, int.MaxValue, null, null, null); var x = blobList.Results.OfType <CloudBlobDirectory>().Select(p => p.Prefix.TrimEnd('/')).ToArray(); return(x); }
public void Tracing() { // Given string inputFolder = Path.Combine(TestContext.CurrentContext.TestDirectory, @".\Input"); if (!Directory.Exists(inputFolder)) { Directory.CreateDirectory(inputFolder); } IExecutionContext context = Substitute.For<IExecutionContext>(); context.RootFolder.Returns(TestContext.CurrentContext.TestDirectory); context.InputFolder.Returns(inputFolder); Engine engine = new Engine(); engine.Configure(); context.Assemblies.Returns(engine.Assemblies); context.Namespaces.Returns(engine.Namespaces); IDocument document = Substitute.For<IDocument>(); TraceListener traceListener = new TraceListener(); Trace.AddListener(traceListener); document.GetStream().Returns(new MemoryStream(Encoding.UTF8.GetBytes(@"@{ Trace.Information(""Test""); }"))); Razor razor = new Razor(); // When razor.Execute(new[] { document }, context).ToList(); // Make sure to materialize the result list // Then Trace.RemoveListener(traceListener); CollectionAssert.Contains(traceListener.Messages, "Test"); }
public virtual void addTraceListener(TraceListener l) { if (!ignoreInvalidDebugCalls) throw new System.ArgumentException("addTraceListener() is only valid if parser built for debugging"); }