internal AsyncMethodWeaver(TypeReferenceProvider typeReferenceProvider, MethodReferenceProvider methodReferenceProvider, ILoggerProvider loggerProvider, MethodDefinition methodDefinition) : base(typeReferenceProvider, methodReferenceProvider, loggerProvider, methodDefinition) { var asyncAttribute = methodDefinition.CustomAttributes.Single(it => it.AttributeType.FullName.Equals(_typeReferenceProvider.AsyncStateMachineAttribute.FullName)); _generatedType = asyncAttribute.ConstructorArguments[0].Value as TypeDefinition; WeavingLog.LogDebug($"Weaving {methodDefinition.FullName}"); }
public void Execute() { WeavingLog.SetLogger(this); var parser = FodyConfigParser.Parse(Config); if (parser.IsErroneous) { LogError(parser.Error); } else { ModuleLevelWeaver.Execute(parser.Result, ModuleDefinition); } }
/// <summary> /// Weaves the tracer to a the module specified in <see cref="ModuleDefinition"/> property. It adds a trace enter and trace leave call to all methods defined by the filter. /// It also replaces static Log calls to logger instance calls and extends the call parameters with method name information. /// It uses the configuration to identify the exact weaver behavior. /// </summary> public override void Execute() { WeavingLog.SetLogger(this); var parser = FodyConfigParser.Parse(Config, GetDefaultConfig()); if (parser.IsErroneous) { LogError(parser.Error); } else { parser.Result.Filter.LogFilterInfo(this); ModuleLevelWeaver.Execute(parser.Result, ModuleDefinition); } }
/// <summary> /// Weaves the logging and tracing into the given module. Please note that the module itself is modified. /// Configuration is used to specify certain weaving behaviors and provide necessary input for the weaver /// </summary> /// <param name="configuration">Configuration information</param> /// <param name="moduleDefinition">Target module</param> public static void Execute(TraceLoggingConfiguration configuration, ModuleDefinition moduleDefinition) { try { WeavingLog.LogInfo("Tracer: Starts weaving."); Stopwatch timer = Stopwatch.StartNew(); ModuleLevelWeaver weaver = new ModuleLevelWeaver(configuration, moduleDefinition); weaver.InternalExecute(); timer.Stop(); WeavingLog.LogInfo(string.Format("Tracer: Weaving done in {0} ms.", timer.ElapsedMilliseconds)); } catch (Exception ex) { WeavingLog.LogError(string.Format("Tracer: Weaving failed with {0}", ex)); throw; } }