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).

#### See also

`message_prefix_stream/4`, `message_tokens//2`, `print_message/3`, `print_message_tokens/3`, `print_message_token/4`
`ask_question/5`, `question_hook/5`, `question_prompt_stream/4`