Package com.p6spy.engine.logging

Examples of com.p6spy.engine.logging.P6LogLoadableOptions


  static boolean isLoggable(String sql) {
  if (null == sql) {
    return false;
  }
 
    final P6LogLoadableOptions opts = P6LogOptions.getActiveInstance();
   
    if (!opts.getFilter()) {
      return true;
    }

    final Pattern sqlExpressionPattern = opts.getSQLExpressionPattern();
    final Pattern includeExcludePattern = opts.getIncludeExcludePattern();
   
    return (sqlExpressionPattern == null || sqlExpressionPattern != null && sqlExpressionPattern.matcher(sql).matches())
        && (includeExcludePattern == null || includeExcludePattern != null && includeExcludePattern.matcher(sql).matches());
  }
View Full Code Here


    return (sqlExpressionPattern == null || sqlExpressionPattern != null && sqlExpressionPattern.matcher(sql).matches())
        && (includeExcludePattern == null || includeExcludePattern != null && includeExcludePattern.matcher(sql).matches());
  }

  static boolean isCategoryOk(Category category) {
    final P6LogLoadableOptions opts = P6LogOptions.getActiveInstance();
    if (null == opts) {
      return CATEGORIES_IMPLICITLY_INCLUDED.contains(category);
    }
   
    final Set<Category> excludeCategories = opts.getExcludeCategoriesSet();
   
    return logger != null && logger.isCategoryEnabled(category)
      && (excludeCategories == null || !excludeCategories.contains(category));
  }
View Full Code Here

  }

  //->JAW: new method that checks to see if this statement should be logged based
  //on whether on not it has taken greater than x amount of time.
  static private boolean meetsThresholdRequirement(long timeTaken) {
        final P6LogLoadableOptions opts = P6LogOptions.getActiveInstance();
        long executionThreshold = null != opts ? opts.getExecutionThreshold() : 0;
   
    return executionThreshold <= 0 || timeTaken > executionThreshold;
  }
View Full Code Here

      System.setProperty(SystemProperties.P6SPY_PREFIX + P6SpyOptions.MODULELIST,
          P6LogFactory.class.getName());
      P6SpyOptions.getActiveInstance().reload();
    }

    final P6LogLoadableOptions opts = P6LogOptions.getActiveInstance();
    Assert.assertNotNull(opts);

    Assert.assertNull(opts.getSQLExpression());
    Assert.assertEquals(0L, opts.getExecutionThreshold());
    Assert.assertEquals("info,debug,result,resultset,batch", opts.getExcludecategories());
    Assert.assertTrue(opts.getExcludeCategoriesSet().containsAll(
        Arrays.asList(DEFAULT_CATEGORIES)));
    Assert.assertFalse(opts.getFilter());
    Assert.assertNull(opts.getIncludeList());
    Assert.assertNull(opts.getExcludeList());
    Assert.assertNull(opts.getIncludeExcludePattern());
    Assert.assertEquals("", opts.getInclude());
    Assert.assertEquals("", opts.getExclude());
    Assert.assertNull(opts.getSQLExpressionPattern());
  }
View Full Code Here

    Assert.assertNull(opts.getRealDataSourceProperties());
  }
 
  @Test
  public void testUnSetLogAPI() {
    final P6LogLoadableOptions opts = P6LogOptions.getActiveInstance();
   
    opts.setSQLExpression("foo");
    Assert.assertEquals("foo", opts.getSQLExpression());
    Assert.assertNotNull(opts.getSQLExpressionPattern());
    opts.unSetSQLExpression();
    Assert.assertNull(opts.getSQLExpression());
    Assert.assertNull(opts.getSQLExpressionPattern());
  }
View Full Code Here

TOP

Related Classes of com.p6spy.engine.logging.P6LogLoadableOptions

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.