Search in sources :

Example 6 with AccountLogger

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());
}
Also used : Account(com.zimbra.cs.account.Account) SoapProvisioning(com.zimbra.cs.account.soap.SoapProvisioning) AccountLogger(com.zimbra.common.util.AccountLogger)

Example 7 with AccountLogger

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);
}
Also used : Account(com.zimbra.cs.account.Account) SoapProvisioning(com.zimbra.cs.account.soap.SoapProvisioning) AccountLogger(com.zimbra.common.util.AccountLogger) List(java.util.List)

Example 8 with AccountLogger

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);
}
Also used : Account(com.zimbra.cs.account.Account) SoapProvisioning(com.zimbra.cs.account.soap.SoapProvisioning) AccountLogger(com.zimbra.common.util.AccountLogger)

Example 9 with AccountLogger

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());
        }
    }
}
Also used : SoapProvisioning(com.zimbra.cs.account.soap.SoapProvisioning) AccountLogger(com.zimbra.common.util.AccountLogger) ArrayList(java.util.ArrayList) List(java.util.List)

Example 10 with AccountLogger

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());
    }
}
Also used : SoapProvisioning(com.zimbra.cs.account.soap.SoapProvisioning) AccountLogger(com.zimbra.common.util.AccountLogger)

Aggregations

AccountLogger (com.zimbra.common.util.AccountLogger)11 Account (com.zimbra.cs.account.Account)8 SoapProvisioning (com.zimbra.cs.account.soap.SoapProvisioning)8 List (java.util.List)4 Test (org.junit.Test)3 Element (com.zimbra.common.soap.Element)2 Server (com.zimbra.cs.account.Server)2 ZimbraSoapContext (com.zimbra.soap.ZimbraSoapContext)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 DistributionList (com.zimbra.cs.account.DistributionList)1 Provisioning (com.zimbra.cs.account.Provisioning)1 GetAllAccountLoggersRequest (com.zimbra.soap.admin.message.GetAllAccountLoggersRequest)1 GetAllAccountLoggersResponse (com.zimbra.soap.admin.message.GetAllAccountLoggersResponse)1 AccountLoggerInfo (com.zimbra.soap.admin.type.AccountLoggerInfo)1