Logtalk 2.15.1 release files.

git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@792 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
pmoura 2003-03-08 10:12:54 +00:00
parent 2572851ad5
commit 4cc9de5707
4 changed files with 145 additions and 0 deletions

View File

@ -0,0 +1,13 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.15.1
Copyright (c) 1998-2003 Paulo Moura. All Rights Reserved.
=================================================================
To load all objects in this library consult the msglog.loader utility
file (note that the *.loader files are Prolog files).
If you need more than one message recorder, just create a new prototype
as an extension of the object msglog.

View File

@ -0,0 +1,46 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.15.1
Copyright (c) 1998-2003 Paulo Moura. All Rights Reserved.
=================================================================
% assume that all library entities have been loaded...
% start recording user messages:
| ?- msglog::record.
yes
% send some messages:
| ?- list::member(X, [1, 2, 3]).
X = 1 ;
X = 2 ;
X = 3 ;
no
| ?- character::is_alpha(p).
yes
| ?- integer::between(1, 4, N).
N = 1 ;
N = 2 ;
N = 3 ;
N = 4 ;
no
% stop recording and print message log:
| ?- msglog::(stop, print).
list::member(X, [1, 2, 3]).
character::is_alpha(p).
integer::between(1, 4, N).
yes

View File

@ -0,0 +1,82 @@
:- object(msglog).
:- info([
version is 1.0,
author is 'Paulo Moura',
date is 2003/03/04,
comment is 'Monitor for recording, replaying, and saving user messages.']).
:- public(record/0).
:- mode(record, one).
:- info(record/0,
[comment is 'Starts recording messages.']).
:- public(stop/0).
:- mode(stop, one).
:- info(stop/0,
[comment is 'Stops recording messages.']).
:- public(replay/0).
:- mode(replay, one).
:- info(replay/0,
[comment is 'Replays all recorded messages.']).
:- public(print/0).
:- mode(print, one).
:- info(print/0,
[comment is 'Prints recorded messages, one per line.']).
:- public(erase/0).
:- mode(erase, one).
:- info(erase/0,
[comment is 'Erases recorded messages.']).
:- private(log_/2).
:- dynamic(log_/2).
:- mode(log_(+object, +nonvar), zero_or_more).
:- info(log_/2,
[comment is 'Table of recorded messages.',
argnames is ['Object', 'Message']]).
record :-
self(Self),
abolish_events(_, _, _, _, Self),
define_events(before, _, _, user, Self).
stop :-
self(Self),
abolish_events(_, _, _, _, Self).
replay :-
self(Self),
abolish_events(_, _, _, _, Self),
forall(::log_(Object, Message), {Object::Message}).
print :-
forall(
::log_(Object, Message),
(writeq(Object), write('::'), writeq(Message), write('.'), nl)).
erase :-
::retractall(log_(_, _)).
before(Object, Message, _) :-
self(Self),
(Self = Object ->
true
;
::assertz(log_(Object, Message))).
:- end_object.

View File

@ -0,0 +1,4 @@
:- initialization(
logtalk_load([
msglog])).