message_hook/4 — The Logtalk Handbook v3.47.0 documentation

# `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.

## Modes and number of proofs

    message_hook(@nonvar, @nonvar, @nonvar, @list(nonvar)) - zero_or_one

## 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/6, question_prompt_stream/4