public void IsLoggingUrl_NoUrlsConfigured_CodeConfig()
        {
            JavascriptLogging.SetJsnlogConfiguration(null, null);

            Assert.True(LoggingUrlHelpers.IsLoggingUrl("/jsnlog.logger"));
            Assert.True(LoggingUrlHelpers.IsLoggingUrl("http://abc.com/jsnlog.logger"));
            Assert.False(LoggingUrlHelpers.IsLoggingUrl("http://abc.com/jsnlog.css"));
        }
Example #2
0
        public static void SetConfigCache(string configXml, ILoggingAdapter logger = null)
        {
            // Set config cache in JavascriptLogging to contents of xe
            XmlElement xe = ConfigToXe(configXml);

            JavascriptLogging.SetJsnlogConfiguration(null, logger);
            JavascriptLogging.GetJsnlogConfiguration(() => xe);
        }
Example #3
0
        protected void Application_BeginRequest()
        {
            // Configure CORS.

            JavascriptLogging.SetJsnlogConfiguration(new JsnlogConfiguration
            {
                defaultAjaxUrl          = "http://apicorslocalhost.local/jsnlog.logger",
                corsAllowedOriginsRegex = @"^https?:\/\/([a-z0-9]+[.])*corslocalhost[.]local$",
                productionLibraryPath   = "~/Scripts/jsnlog.min.js"
            });
        }
Example #4
0
        public void SetConfigWithJsnlogInWebConfig()
        {
            // Arrange

            string configXml = @"
                <jsnlog maxMessages=""5"">
</jsnlog>
";

            XmlElement          xe = CommonTestHelpers.ConfigToXe(configXml);
            JsnlogConfiguration jsnlogConfiguration = new JsnlogConfiguration();

            // Act

            Exception ex = Assert.Throws <ConflictingConfigException>(() => JavascriptLogging.SetJsnlogConfiguration(() => xe, jsnlogConfiguration));
        }
        protected void Application_BeginRequest()
        {
            // Use configuration in code instead of configuration in web.config/.

            JavascriptLogging.SetJsnlogConfiguration(new JsnlogConfiguration
            {
                serverSideMessageFormat = "%userHostAddress, %logger, %level, %message",
                productionLibraryPath   = "~/Scripts/jsnlog.min.js",
                loggers = new List <Logger>
                {
                    new Logger
                    {
                        name  = "jsLogger",
                        level = "FATAL"
                    }
                }
            });
        }
Example #6
0
        public void SetConfigWithoutJsnlogInWebConfig()
        {
            // Arrange

            JsnlogConfiguration jsnlogConfiguration = new JsnlogConfiguration
            {
                maxMessages = 5
            };

            JavascriptLogging.SetJsnlogConfiguration(() => null, jsnlogConfiguration);

            // Act

            JsnlogConfiguration retrievedJsnlogConfiguration = JavascriptLogging.GetJsnlogConfiguration();

            // Assert

            // Retrieved object is expected to be the exact same object that was put in
            Assert.Equal(jsnlogConfiguration, retrievedJsnlogConfiguration);
            Assert.Equal(jsnlogConfiguration.maxMessages, retrievedJsnlogConfiguration.maxMessages);
        }
Example #7
0
        public void GetConfigFromWebConfig()
        {
            // Arrange

            string     configXml = @"
                <jsnlog maxMessages=""5"">
</jsnlog>
";
            XmlElement xe        = CommonTestHelpers.ConfigToXe(configXml);

            JavascriptLogging.SetJsnlogConfiguration(null);
            JavascriptLogging.GetJsnlogConfiguration(() => xe);

            // Act

            JsnlogConfiguration retrievedJsnlogConfiguration = JavascriptLogging.GetJsnlogConfiguration();

            // Assert

            // Retrieved object is expected to be the exact same object that was put in
            Assert.Equal((uint)5, retrievedJsnlogConfiguration.maxMessages);
        }
Example #8
0
 private void RunTest(JsnlogConfiguration jsnlogConfiguration)
 {
     JavascriptLogging.SetJsnlogConfiguration(() => null, jsnlogConfiguration);
     JsnlogConfiguration retrievedJsnlogConfiguration = JavascriptLogging.GetJsnlogConfiguration();
 }