use of com.zimbra.common.util.AccountLogger in project zm-mailbox by Zimbra.
the class TestLog method testRemoveAll.
/**
* Tests removing all account loggers for a given account.
*/
public void testRemoveAll() throws Exception {
SoapProvisioning prov = TestUtil.newSoapProvisioning();
Account user1 = TestUtil.getAccount("user1");
Account user2 = TestUtil.getAccount("user2");
prov.addAccountLogger(user1, "zimbra.soap", "debug", null);
prov.addAccountLogger(user1, "zimbra.sync", "debug", null);
prov.addAccountLogger(user2, "zimbra.soap", "debug", null);
prov.addAccountLogger(user2, "zimbra.sync", "debug", null);
// Test removing loggers with no category specified.
List<AccountLogger> loggers = prov.getAccountLoggers(user1, null);
assertEquals(2, loggers.size());
prov.removeAccountLoggers(user1, null, null);
loggers = prov.getAccountLoggers(user1, null);
assertEquals(0, loggers.size());
// Test removing loggers with category "all".
loggers = prov.getAccountLoggers(user2, null);
assertEquals(2, loggers.size());
prov.removeAccountLoggers(user2, "all", null);
loggers = prov.getAccountLoggers(user2, null);
assertEquals(0, loggers.size());
}
use of com.zimbra.common.util.AccountLogger in project zm-mailbox by Zimbra.
the class TestLog method testAccountLoggers.
public void testAccountLoggers() throws Exception {
SoapProvisioning prov = TestUtil.newSoapProvisioning();
Account user1 = TestUtil.getAccount("user1");
Account user2 = TestUtil.getAccount("user2");
Account user3 = TestUtil.getAccount("user3");
Account user4 = TestUtil.getAccount("user4");
// Add loggers.
List<AccountLogger> loggers = prov.addAccountLogger(user1, "zimbra.filter", "debug", null);
assertLoggerExists(loggers, user1, "zimbra.filter", Level.debug);
loggers = prov.addAccountLogger(user2, "zimbra.backup", "info", null);
assertLoggerExists(loggers, user2, "zimbra.backup", Level.info);
loggers = prov.addAccountLogger(user3, "zimbra.sync", "warn", null);
assertLoggerExists(loggers, user3, "zimbra.sync", Level.warn);
loggers = prov.addAccountLogger(user3, "zimbra.lmtp", "warn", null);
assertLoggerExists(loggers, user3, "zimbra.lmtp", Level.warn);
assertEquals(1, loggers.size());
loggers = prov.addAccountLogger(user4, "zimbra.lmtp", "error", null);
assertLoggerExists(loggers, user4, "zimbra.lmtp", Level.error);
// Verify <GetAccountLoggersRequest>.
loggers = prov.getAccountLoggers(user1, null);
assertEquals(1, loggers.size());
assertLoggerExists(loggers, user1, "zimbra.filter", Level.debug);
loggers = prov.getAccountLoggers(user2, null);
assertEquals(1, loggers.size());
assertLoggerExists(loggers, user2, "zimbra.backup", Level.info);
loggers = prov.getAccountLoggers(user3, null);
assertEquals(2, loggers.size());
assertLoggerExists(loggers, user3, "zimbra.sync", Level.warn);
assertLoggerExists(loggers, user3, "zimbra.lmtp", Level.warn);
loggers = prov.getAccountLoggers(user4, null);
assertEquals(1, loggers.size());
assertLoggerExists(loggers, user4, "zimbra.lmtp", Level.error);
// Remove loggers for everyone except user3.
prov.removeAccountLoggers(user1, "zimbra.filter", null);
prov.removeAccountLoggers(user2, null, null);
prov.removeAccountLoggers(user4, null, null);
// Test <GetAllAccountLoggersRequest>.
Map<String, List<AccountLogger>> map = prov.getAllAccountLoggers(null);
assertEquals(1, map.size());
loggers = map.get(user3.getName());
assertEquals(2, loggers.size());
assertLoggerExists(loggers, user3, "zimbra.sync", Level.warn);
assertLoggerExists(loggers, user3, "zimbra.lmtp", Level.warn);
}
use of com.zimbra.common.util.AccountLogger in project zm-mailbox by Zimbra.
the class TestLog method testAllCategories.
/**
* Confirms that account loggers are added for all categories when the
* category name is set to "all" (bug 29715).
*/
public void testAllCategories() throws Exception {
SoapProvisioning prov = TestUtil.newSoapProvisioning();
Account account = TestUtil.getAccount("user1");
assertEquals(0, prov.getAccountLoggers(account, null).size());
List<AccountLogger> loggers = prov.addAccountLogger(account, "all", "debug", null);
assertTrue(loggers.size() > 1);
// Make sure the zimbra.soap category was affected.
assertLoggerExists(loggers, account, "zimbra.soap", Level.debug);
loggers = prov.getAccountLoggers(account, null);
assertLoggerExists(loggers, account, "zimbra.soap", Level.debug);
}
use of com.zimbra.common.util.AccountLogger in project zm-mailbox by Zimbra.
the class ProvUtil method doGetAllAccountLoggers.
private void doGetAllAccountLoggers(AccountLoggerOptions alo) throws ServiceException {
if (!(prov instanceof SoapProvisioning)) {
throwSoapOnly();
}
SoapProvisioning sp = (SoapProvisioning) prov;
Map<String, List<AccountLogger>> allLoggers = sp.getAllAccountLoggers(alo.server);
for (String accountName : allLoggers.keySet()) {
console.printf("# name %s\n", accountName);
for (AccountLogger logger : allLoggers.get(accountName)) {
console.printf("%s=%s\n", logger.getCategory(), logger.getLevel());
}
}
}
use of com.zimbra.common.util.AccountLogger in project zm-mailbox by Zimbra.
the class ProvUtil method doGetAccountLoggers.
private void doGetAccountLoggers(AccountLoggerOptions alo) throws ServiceException {
if (!(prov instanceof SoapProvisioning)) {
throwSoapOnly();
}
SoapProvisioning sp = (SoapProvisioning) prov;
Account acct = lookupAccount(alo.args[1]);
for (AccountLogger accountLogger : sp.getAccountLoggers(acct, alo.server)) {
console.printf("%s=%s\n", accountLogger.getCategory(), accountLogger.getLevel());
}
}
Aggregations