Esempio n. 1
0
 public TypeReferenceProvider(TraceLoggingConfiguration configuration, ILoggerAdapterMetadataScopeProvider loggerAdapterMetadataScopeProvider, ModuleDefinition moduleDefinition)
 {
     _configuration    = configuration;
     _moduleDefinition = moduleDefinition;
     _loggerAdapterMetadataScopeProvider = loggerAdapterMetadataScopeProvider;
     _stringArray = new Lazy <TypeReference>(() => moduleDefinition.ImportReference((typeof(string[]))));
     _objectArray = new Lazy <TypeReference>(() => moduleDefinition.ImportReference(typeof(object[])));
     _type        = new Lazy <TypeReference>(() => moduleDefinition.ImportReference(typeof(Type)));
     _stopwatch   = new Lazy <TypeReference>(() => moduleDefinition.ImportReference(typeof(Stopwatch)));
     _exception   = new Lazy <TypeReference>(() => moduleDefinition.ImportReference(typeof(Exception)));
     _asyncStateMachineAttribute = new Lazy <TypeReference>(() => moduleDefinition.ImportReference(
                                                                typeof(System.Runtime.CompilerServices.AsyncStateMachineAttribute)));
     _task = new Lazy <TypeReference>(() => moduleDefinition.ImportReference(typeof(Task)));
 }
Esempio n. 2
0
        /// <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.");
                var timer  = Stopwatch.StartNew();
                var 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;
            }
        }
Esempio n. 3
0
 private ModuleLevelWeaver(TraceLoggingConfiguration configuration, ModuleDefinition moduleDefinition)
 {
     _configuration    = configuration;
     _moduleDefinition = moduleDefinition;
 }