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:
parent
2572851ad5
commit
4cc9de5707
13
Logtalk/examples/msglog/NOTES
Normal file
13
Logtalk/examples/msglog/NOTES
Normal 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.
|
||||
|
46
Logtalk/examples/msglog/SCRIPT
Normal file
46
Logtalk/examples/msglog/SCRIPT
Normal 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
|
||||
|
82
Logtalk/examples/msglog/msglog.lgt
Normal file
82
Logtalk/examples/msglog/msglog.lgt
Normal 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.
|
||||
|
4
Logtalk/examples/msglog/msglog.loader
Normal file
4
Logtalk/examples/msglog/msglog.loader
Normal file
@ -0,0 +1,4 @@
|
||||
|
||||
:- initialization(
|
||||
logtalk_load([
|
||||
msglog])).
|
Reference in New Issue
Block a user