This is a debug message, output when a library (whose index in the list
of libraries (being) loaded is given) registers a callout.
-% HOOKS_HOOK_REGISTERED hook %1 was registered
-This is a debug message indicating that a hook of the specified name
-was registered by a BIND 10 server. The server doing the logging is
-indicated by the full name of the logger used to log this message.
-
% HOOKS_STD_CALLOUT_REGISTERED hooks library %1 registered standard callout for hook %2 at address %3
This is a debug message, output when the library loading function has
located a standard callout (a callout with the same name as a hook point)
// Constructor - register the pre-defined hooks and check that the indexes
// assigned to them are as expected.
+//
+// Note that there are no logging messages here or in registerHooks(). One
+// method to initialize hook names is to use static initialization. Here,
+// a static object is declared in a file outside of any function or method.
+// As a result, it is instantiated and its constructor run before the main
+// program starts. By putting calls to ServerHooks::registerHook() in there,
+// hooks names are already registered when the program runs. However, at that
+// point, the logging system is not initialized, so messages are unable to
+// be output.
ServerHooks::ServerHooks() {
- reset();
+ initialize();
}
// Register a hook. The index assigned to the hook is the current number
// Element was inserted, so add to the inverse hooks collection.
inverse_hooks_[index] = name;
- // Log it if debug is enabled
- LOG_DEBUG(hooks_logger, HOOKS_DBG_TRACE, HOOKS_HOOK_REGISTERED).arg(name);
-
// ... and return numeric index.
return (index);
}
-// Reset ServerHooks object to initial state.
+// Set ServerHooks object to initial state.
void
-ServerHooks::reset() {
+ServerHooks::initialize() {
// Clear out the name->index and index->name maps.
hooks_.clear();
". context_destroy: expected = " << CONTEXT_DESTROY <<
", actual = " << destroy);
}
+}
+
+// Reset ServerHooks object to initial state.
+
+void
+ServerHooks::reset() {
+
+ // Clear all hooks then initialize the pre-defined ones.
+ initialize();
// Log a warning - although this is done during testing, it should never be
// seen in a production system.
///
/// Resets the collection of hooks to the initial state, with just the
/// context_create and context_destroy hooks set. This used during
- /// construction. It is also used during testing to reset the global
- /// ServerHooks object.
+ /// testing to reset the global ServerHooks object; it should never be
+ /// used in production.
///
/// @throws isc::Unexpected if the registration of the pre-defined hooks
/// fails in some way.
/// fails in some way.
ServerHooks();
+ /// @brief Initialize hooks
+ ///
+ /// Sets the collection of hooks to the initial state, with just the
+ /// context_create and context_destroy hooks set. This used during
+ /// construction.
+ ///
+ /// @throws isc::Unexpected if the registration of the pre-defined hooks
+ /// fails in some way.
+ void initialize();
+
/// Useful typedefs.
typedef std::map<std::string, int> HookCollection;
typedef std::map<int, std::string> InverseHookCollection;