diff options
author | Gabriel Russell <gabriel.russell@mongodb.com> | 2020-02-13 11:49:46 -0500 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-02-13 18:16:35 +0000 |
commit | a84c09a19720b73cedb2e8ef7c5cfeedfa1c9761 (patch) | |
tree | 85ac46cd5f4ea6d5134560bf764fb9e6cf11fe4e /src/mongo/db/auth/authorization_manager_impl.cpp | |
parent | 6df40e01f7b6899affc4536e7e73a35802cabf98 (diff) | |
download | mongo-a84c09a19720b73cedb2e8ef7c5cfeedfa1c9761.tar.gz |
SERVER-45869 automatically converted structured logging
Diffstat (limited to 'src/mongo/db/auth/authorization_manager_impl.cpp')
-rw-r--r-- | src/mongo/db/auth/authorization_manager_impl.cpp | 43 |
1 files changed, 28 insertions, 15 deletions
diff --git a/src/mongo/db/auth/authorization_manager_impl.cpp b/src/mongo/db/auth/authorization_manager_impl.cpp index f996254981d..603cf4c924c 100644 --- a/src/mongo/db/auth/authorization_manager_impl.cpp +++ b/src/mongo/db/auth/authorization_manager_impl.cpp @@ -51,6 +51,7 @@ #include "mongo/db/auth/user_management_commands_parser.h" #include "mongo/db/global_settings.h" #include "mongo/db/mongod_options.h" +#include "mongo/logv2/log.h" #include "mongo/util/assert_util.h" #include "mongo/util/log.h" #include "mongo/util/str.h" @@ -413,7 +414,7 @@ StatusWith<UserHandle> AuthorizationManagerImpl::acquireUser(OperationContext* o auto cachedUser = _userCache.acquire(opCtx, userName); invariant(cachedUser); - LOG(1) << "Returning user " << userName << " from cache"; + LOGV2_DEBUG(20226, 1, "Returning user {userName} from cache", "userName"_attr = userName); return cachedUser; } catch (const DBException& ex) { return ex.toStatus(); @@ -442,7 +443,7 @@ void AuthorizationManagerImpl::updatePinnedUsersList(std::vector<UserName> names bool noUsersToPin = _usersToPin->empty(); _pinnedUsersCond.notify_one(); if (noUsersToPin) { - LOG(1) << "There were no users to pin, not starting tracker thread"; + LOGV2_DEBUG(20227, 1, "There were no users to pin, not starting tracker thread"); return; } @@ -456,7 +457,7 @@ void AuthorizationManagerImpl::_pinnedUsersThreadRoutine() noexcept try { Client::initThread("PinnedUsersTracker"); std::list<UserHandle> pinnedUsers; std::vector<UserName> usersToPin; - LOG(1) << "Starting pinned users tracking thread"; + LOGV2_DEBUG(20228, 1, "Starting pinned users tracking thread"); while (true) { auto opCtx = cc().makeOperationContext(); @@ -485,13 +486,22 @@ void AuthorizationManagerImpl::_pinnedUsersThreadRoutine() noexcept try { if (!user.isValid() || !shouldPin) { if (!shouldPin) { - LOG(2) << "Unpinning user " << user->getName(); + LOGV2_DEBUG(20229, + 2, + "Unpinning user {user_getName}", + "user_getName"_attr = user->getName()); } else { - LOG(2) << "Pinned user no longer valid, will re-pin " << user->getName(); + LOGV2_DEBUG(20230, + 2, + "Pinned user no longer valid, will re-pin {user_getName}", + "user_getName"_attr = user->getName()); } it = pinnedUsers.erase(it); } else { - LOG(3) << "Pinned user is still valid and pinned " << user->getName(); + LOGV2_DEBUG(20231, + 3, + "Pinned user is still valid and pinned {user_getName}", + "user_getName"_attr = user->getName()); ++it; } } @@ -506,42 +516,45 @@ void AuthorizationManagerImpl::_pinnedUsersThreadRoutine() noexcept try { auto swUser = acquireUser(opCtx.get(), userName); if (swUser.isOK()) { - LOG(2) << "Pinned user " << userName; + LOGV2_DEBUG(20232, 2, "Pinned user {userName}", "userName"_attr = userName); pinnedUsers.emplace_back(std::move(swUser.getValue())); } else { const auto& status = swUser.getStatus(); // If the user is not found, then it might just not exist yet. Skip this user for // now. if (status != ErrorCodes::UserNotFound) { - warning() << "Unable to fetch pinned user " << userName.toString() << ": " - << status; + LOGV2_WARNING(20239, + "Unable to fetch pinned user {userName}: {status}", + "userName"_attr = userName.toString(), + "status"_attr = status); } else { - LOG(2) << "Pinned user not found: " << userName; + LOGV2_DEBUG( + 20233, 2, "Pinned user not found: {userName}", "userName"_attr = userName); } } } } } catch (const ExceptionFor<ErrorCodes::InterruptedAtShutdown>&) { - LOG(1) << "Ending pinned users tracking thread"; + LOGV2_DEBUG(20234, 1, "Ending pinned users tracking thread"); return; } void AuthorizationManagerImpl::invalidateUserByName(OperationContext* opCtx, const UserName& userName) { - LOG(2) << "Invalidating user " << userName; + LOGV2_DEBUG(20235, 2, "Invalidating user {userName}", "userName"_attr = userName); _authSchemaVersionCache.invalidateAll(); _userCache.invalidate(userName); } void AuthorizationManagerImpl::invalidateUsersFromDB(OperationContext* opCtx, StringData dbname) { - LOG(2) << "Invalidating all users from database " << dbname; + LOGV2_DEBUG(20236, 2, "Invalidating all users from database {dbname}", "dbname"_attr = dbname); _authSchemaVersionCache.invalidateAll(); _userCache.invalidateIf( [&](const UserName& user, const User*) { return user.getDB() == dbname; }); } void AuthorizationManagerImpl::invalidateUserCache(OperationContext* opCtx) { - LOG(2) << "Invalidating user cache"; + LOGV2_DEBUG(20237, 2, "Invalidating user cache"); _authSchemaVersionCache.invalidateAll(); _userCache.invalidateAll(); } @@ -603,7 +616,7 @@ AuthorizationManagerImpl::UserCacheImpl::UserCacheImpl( boost::optional<User> AuthorizationManagerImpl::UserCacheImpl::lookup(OperationContext* opCtx, const UserName& userName) { - LOG(1) << "Getting user " << userName << " from disk"; + LOGV2_DEBUG(20238, 1, "Getting user {userName} from disk", "userName"_attr = userName); // Number of times to retry a user document that fetches due to transient AuthSchemaIncompatible // errors. These errors should only ever occur during and shortly after schema upgrades. |