Exemplo n.º 1
0
        public void Initialize(ModuleDeclaration module)
        {
            this.module = module;
            this.loggingImplementation = new LoggingImplementationTypeBuilder(module);
            this.loggerType = module.FindType(typeof(Logger));

            LoggerMethodsBuilder builder = new LoggerMethodsBuilder(module, this.loggerType);

            this.categoryInitializerMethod = module.FindMethod(module.FindType(typeof(LogManager)), "GetLogger",
                method => method.Parameters.Count == 1 && IntrinsicTypeSignature.Is(method.Parameters[0].ParameterType, IntrinsicType.String) );

            this.loggerMethods[LogLevel.Debug] = builder.CreateLoggerMethods("Trace");
            this.loggerMethods[LogLevel.Info] = builder.CreateLoggerMethods("Info");
            this.loggerMethods[LogLevel.Warning] = builder.CreateLoggerMethods("Warn");
            this.loggerMethods[LogLevel.Error] = builder.CreateLoggerMethods("Error");
            this.loggerMethods[LogLevel.Fatal] = builder.CreateLoggerMethods("Fatal");
        }
Exemplo n.º 2
0
        public void Initialize(ModuleDeclaration module)
        {
            this.module = module;
            this.loggingImplementation = new LoggingImplementationTypeBuilder(module);
            this.loggerType            = module.FindType(typeof(Logger));

            LoggerMethodsBuilder builder = new LoggerMethodsBuilder(module, this.loggerType);

            this.categoryInitializerMethod = module.FindMethod(module.FindType(typeof(LogManager)), "GetLogger",
                                                               method =>
                                                               method.Parameters.Count == 1 &&
                                                               IntrinsicTypeSignature.Is(method.Parameters[0].ParameterType, IntrinsicType.String));

            this.loggerMethods[LogLevel.Debug]   = builder.CreateLoggerMethods("Trace");
            this.loggerMethods[LogLevel.Info]    = builder.CreateLoggerMethods("Info");
            this.loggerMethods[LogLevel.Warning] = builder.CreateLoggerMethods("Warn");
            this.loggerMethods[LogLevel.Error]   = builder.CreateLoggerMethods("Error");
            this.loggerMethods[LogLevel.Fatal]   = builder.CreateLoggerMethods("Fatal");
        }