Exemplo n.º 1
0
        private static void Configure(INewRelicConfig config)
        {
            config = config ?? NewRelicConfig.Instance;
            LoggingConfiguration loggingConfiguration = new LoggingConfiguration();
            ColoredConsoleTarget consoleTarget = new ColoredConsoleTarget { Name = "Console" };
            loggingConfiguration.AddTarget("Console", consoleTarget);
            loggingConfiguration.LoggingRules.Add(new LoggingRule("*", ToNLogLevel(config.LogLevel), consoleTarget));

            // Store the LogLevel so it can be fetched by consumers
            LogLevel = config.LogLevel;

            if (config.LogFilePath.IsValidString() && config.LogFileName.IsValidString())
            {
                long archiveAboveSize = config.LogLimitInKiloBytes == 0 ? long.MaxValue : config.LogLimitInKiloBytes * 1024;
                FileTarget fileTarget = new FileTarget
                {
                    KeepFileOpen = true,
                    ConcurrentWrites = false,
                    FileName = Path.Combine(config.LogFilePath, config.LogFileName),
                    MaxArchiveFiles = 1,
                    ArchiveAboveSize = archiveAboveSize,
                    Name = "File",
                };

                loggingConfiguration.AddTarget("File", fileTarget);
                loggingConfiguration.LoggingRules.Add(new LoggingRule("*", ToNLogLevel(config.LogLevel), fileTarget));
            }

            NLogManager.Configuration = loggingConfiguration;
        }
Exemplo n.º 2
0
        private static void Configure(INewRelicConfig config)
        {
            config = config ?? NewRelicConfig.Instance;
            LoggingConfiguration loggingConfiguration = new LoggingConfiguration();
            ColoredConsoleTarget consoleTarget        = new ColoredConsoleTarget {
                Name = "Console"
            };

            loggingConfiguration.AddTarget("Console", consoleTarget);
            loggingConfiguration.LoggingRules.Add(new LoggingRule("*", ToNLogLevel(config.LogLevel), consoleTarget));

            // Store the LogLevel so it can be fetched by consumers
            LogLevel = config.LogLevel;

            if (config.LogFilePath.IsValidString() && config.LogFileName.IsValidString())
            {
                long       archiveAboveSize = config.LogLimitInKiloBytes == 0 ? long.MaxValue : config.LogLimitInKiloBytes * 1024;
                FileTarget fileTarget       = new FileTarget
                {
                    KeepFileOpen     = true,
                    ConcurrentWrites = false,
                    FileName         = Path.Combine(config.LogFilePath, config.LogFileName),
                    MaxArchiveFiles  = 1,
                    ArchiveAboveSize = archiveAboveSize,
                    Name             = "File",
                };

                loggingConfiguration.AddTarget("File", fileTarget);
                loggingConfiguration.LoggingRules.Add(new LoggingRule("*", ToNLogLevel(config.LogLevel), fileTarget));
            }

            NLogManager.Configuration = loggingConfiguration;
        }
Exemplo n.º 3
0
        /// <summary>
        /// This class is responsible for maintaining metrics that have been reported as well as sending them to the New Relic 
        /// service. Any Components that share a Request reference will have their data sent to the service in one request.
        /// </summary>
        /// <param name="licenseKey">The New Relic license key.</param>
        /// <param name="config">The configuration that should be used.</param>
        public Context(string licenseKey, INewRelicConfig config = null)
        {
            this._newRelicConfig = config ?? NewRelicConfig.Instance;

            this._licenseKey = licenseKey;
            this._requestData = new RequestData();

            s_log.Debug("Using service URL: {0}", this.ServiceUri);
            s_log.Debug("Using license key: {0}", this.LicenseKey);
        }
Exemplo n.º 4
0
        /// <summary>
        /// This class is responsible for maintaining metrics that have been reported as well as sending them to the New Relic
        /// service. Any Components that share a Request reference will have their data sent to the service in one request.
        /// </summary>
        /// <param name="licenseKey">The New Relic license key.</param>
        /// <param name="config">The configuration that should be used.</param>
        public Context(string licenseKey, INewRelicConfig config = null)
        {
            this._newRelicConfig = config ?? NewRelicConfig.Instance;

            this._licenseKey  = licenseKey;
            this._requestData = new RequestData();

            s_log.Debug("Using service URL: {0}", this.ServiceUri);
            s_log.Debug("Using license key: {0}", this.LicenseKey);
        }
Exemplo n.º 5
0
        // methods in this region should only be called directly by tests
        #region CalledByTests

        internal static Logger GetLogger(string className, INewRelicConfig config)
        {
            if (!Configured || config != null)
            {
                lock (ConfigureLock)
                {
                    if (!Configured || config != null)
                    {
                        Configure(config);
                        Configured = true;
                    }
                }
            }

            return(new Logger(className));
        }
Exemplo n.º 6
0
        public Runner(INewRelicConfig config = null)
        {
            this.newRelicConfig = config ?? NewRelicConfig.Instance;

            _factories = new List <AgentFactory>();
            _agents    = new List <Agent>();

            this.SetupProxy(
                this.newRelicConfig.ProxyHost,
                this.newRelicConfig.ProxyPort,
                this.newRelicConfig.ProxyUserName,
                this.newRelicConfig.ProxyPassword);

            // used for testing purposes
            _limit    = this.newRelicConfig.NewRelicMaxIterations.GetValueOrDefault();
            _limitRun = this.newRelicConfig.NewRelicMaxIterations.HasValue;
        }
Exemplo n.º 7
0
        public Runner(INewRelicConfig config = null)
        {
            this.newRelicConfig = config ?? NewRelicConfig.Instance;

            _factories = new List<AgentFactory>();
            _agents = new List<Agent>();

            this.SetupProxy(
                this.newRelicConfig.ProxyHost,
                this.newRelicConfig.ProxyPort,
                this.newRelicConfig.ProxyUserName,
                this.newRelicConfig.ProxyPassword);

            // used for testing purposes
            _limit = this.newRelicConfig.NewRelicMaxIterations.GetValueOrDefault();
            _limitRun = this.newRelicConfig.NewRelicMaxIterations.HasValue;
        }
Exemplo n.º 8
0
 /// <summary>
 /// This class is responsible for maintaining metrics that have been reported as well as sending them to the New Relic 
 /// service. Any Components that share a Request reference will have their data sent to the service in one request.
 /// </summary>
 /// <param name="config">The configuration that should be used.</param>
 public Context(INewRelicConfig config = null)
     : this(null, config)
 {
 }
Exemplo n.º 9
0
 /// <summary>
 /// This class is responsible for maintaining metrics that have been reported as well as sending them to the New Relic
 /// service. Any Components that share a Request reference will have their data sent to the service in one request.
 /// </summary>
 /// <param name="config">The configuration that should be used.</param>
 public Context(INewRelicConfig config = null)
     : this(null, config)
 {
 }
Exemplo n.º 10
0
        // methods in this region should only be called directly by tests
        #region CalledByTests

        internal static Logger GetLogger(string className, INewRelicConfig config)
        {
            if (!Configured || config != null)
            {
                lock (ConfigureLock)
                {
                    if (!Configured || config != null)
                    {
                        Configure(config);
                        Configured = true;
                    }
                }
            }

            return new Logger(className);
        }