|
Revision 4601, 0.6 KB
(checked in by pmoura, 7 weeks ago)
|
|
Added svn:mime-type property to source files (set to text/x-logtalk).
|
-
Property svn:mime-type set to
text/x-logtalk
-
Property svn:eol-style set to
native
|
| Line | |
|---|
| 1 | |
|---|
| 2 | :- category(logging). |
|---|
| 3 | |
|---|
| 4 | :- public([ |
|---|
| 5 | init_log/0, |
|---|
| 6 | add_log_entry/1, |
|---|
| 7 | print_log/0, |
|---|
| 8 | log_entry/2]). |
|---|
| 9 | |
|---|
| 10 | :- private(log_/2). |
|---|
| 11 | :- dynamic(log_/2). |
|---|
| 12 | |
|---|
| 13 | init_log :- |
|---|
| 14 | retractall(log_(_, _)), |
|---|
| 15 | add_log_entry(start). |
|---|
| 16 | |
|---|
| 17 | add_log_entry(Entry) :- |
|---|
| 18 | date::today(Year, Month, Day), |
|---|
| 19 | time::now(Hours, Mins, Secs), |
|---|
| 20 | assertz(log_(Year/Month/Day-Hours:Mins:Secs, Entry)). |
|---|
| 21 | |
|---|
| 22 | print_log :- |
|---|
| 23 | this(This), |
|---|
| 24 | This::log_(Date, Entry), |
|---|
| 25 | write(Date), write(' - '), write(Entry), nl, |
|---|
| 26 | fail. |
|---|
| 27 | print_log. |
|---|
| 28 | |
|---|
| 29 | log_entry(Date, Entry) :- |
|---|
| 30 | this(This), |
|---|
| 31 | This::log_(Date, Entry). |
|---|
| 32 | |
|---|
| 33 | :- end_category. |
|---|
| 34 | |
|---|
| 35 | |
|---|
| 36 | :- object(object, |
|---|
| 37 | imports(logging)). |
|---|
| 38 | |
|---|
| 39 | :- initialization(:init_log). |
|---|
| 40 | |
|---|
| 41 | :- end_object. |
|---|