Logtalk reference manual
Built-in method: message_hook/4
Contents > Reference Manual > Built-in Methods > message_hook/4

## message_hook/4

#### Description

    message_hook(Message, Kind, Component, Tokens)

User-defined hook method for intercepting printing of a message, declared in the `logtalk` built-in object as a public, multifile, and dynamic predicate. This hook method is automatically called by the `print_message/3` method. When the call succeeds, the `print_message/3` method assumes that the message have been successfully printed.

#### Template and modes

    message_hook(@callable, @callable, @callable, @list(nonvar))

#### Errors

`(none)`

#### Examples

    :- multifile(logtalk::message_hook/4).
    :- dynamic(logtalk::message_hook/4).

    % print silent messages instead of discarding them as default
    logtalk::message_hook(_, silent, core, Tokens) :-
        logtalk::message_prefix_stream(silent, core, Prefix, Stream),
        logtalk::print_message_tokens(Stream, Prefix, Tokens).