Package at.ipsquare.commons.core.util

Examples of at.ipsquare.commons.core.util.PerformanceLogger


     * Meant to cover the full functionality of our {@link PerformanceLogger}.
     */
    @Test
    public void test() throws InterruptedException
    {
        final PerformanceLogger plog = new PerformanceLogger();
        Thread.sleep(1);
        plog.logElapsed();
       
        assertThat(logString(), containsString(TestPerformanceLogger.class.getSimpleName()));
        assertThat(logString(), containsString("test"));
       
        new InnerClass(plog);
        plog.logElapsed("asdf");
       
        assertThat(logString(), containsString("asdf"));
        assertThat(logString(), containsString(InnerClass.class.getSimpleName()));
       
        new Object()
        {
            {
                plog.logElapsedAndRestart("obj");
            }
           
            void strangeConstructIndeed()
            {
                plog.logElapsed("strange");
            }
        }.strangeConstructIndeed();
       
        assertThat(logString(), containsString("obj"));
        assertThat(logString(), containsString("strangeConstructIndeed"));
       
        new Runnable()
        {
            @Override
            public void run()
            {
                plog.logElapsed("running away");
            }
        }.run();
       
        assertThat(logString(), containsString("running"));
       
        PerformanceLogger plog2 = new PerformanceLogger(1000);
        plog2.logElapsed("should-never-be-logged");
        assertThat(logString(), not(containsString("should-never-be-logged")));
        Thread.sleep(1500);
        plog2.logElapsed("should-be-logged");
        assertThat(logString(), containsString("should-be-logged"));
       
        Logger logbackLogger = (Logger) LoggerFactory.getLogger(PerformanceLogger.class);
        logbackLogger.setLevel(Level.ERROR);
        plog.logElapsedAndRestart("do-not-log-me");
View Full Code Here


    {
        static class InnerInnerClass
        {
            void doStuff() throws InterruptedException
            {
                PerformanceLogger plog = new PerformanceLogger();
                Thread.sleep(5);
                plog.logElapsed("done, bastards");
            }
View Full Code Here

        if(!requestMatcher.matches(req))
            chain.doFilter(req, res);
        else
        {
            Throwable th = null;
            PerformanceLogger plog = new PerformanceLogger(threshold, performanceLogFormatter());
            try
            {
                chain.doFilter(req, res);
            }
            catch(Throwable e)
            {
                th = e;
            }
            finally
            {
                plog.logElapsed(toLogString(req, res, th));
            }
           
            if(th != null)
            {
                if(th instanceof IOException)
View Full Code Here

TOP

Related Classes of at.ipsquare.commons.core.util.PerformanceLogger

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.