Skip to content

Commit 1136bca

Browse files
author
skitoo
committed
add formatting message description in README file
1 parent 9466309 commit 1136bca

File tree

1 file changed

+53
-12
lines changed

1 file changed

+53
-12
lines changed

README.rst

Lines changed: 53 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Rozenn is a Flash/AS3 logging system strongly inspired by the famous `Log4J <htt
55

66
Installation
77
============
8-
The best way to use Rozenn is by adding the provided SWC file to your project. But you can download source code and put it in your classpath.
8+
The best way to install Rozenn is by adding the provided SWC file to your project. But you can download source code and put it in your classpath.
99

1010
Usage
1111
=====
@@ -16,15 +16,15 @@ The logger is the basic entity of the system logger. He is represented by the cl
1616

1717
::
1818

19-
package
20-
{
21-
import org.rozenn.Logger;
22-
23-
public class MyClass
19+
package
2420
{
25-
private static var logger : Logger = Logger.getLogger(MyClass);
21+
import org.rozenn.Logger;
22+
23+
public class MyClass
24+
{
25+
private static var logger : Logger = Logger.getLogger(MyClass);
26+
}
2627
}
27-
}
2828
2929
As you can see the declaration of a logger is very simple. It is done by the static method **Logger.getLogger**. This one take parent class name as parameter. You can give a different name but it is preferable to use the class to be used by the system of hierarchy and configuration.
3030

@@ -51,10 +51,10 @@ To log a message several methods of the Logger available to you:
5151

5252
::
5353

54-
logger.log(Level.DEBUG, "debug message");
55-
56-
// the same with debug method
57-
logger.debug("debug message");
54+
logger.log(Level.DEBUG, "debug message");
55+
56+
// the same with debug method
57+
logger.debug("debug message");
5858
5959

6060
Of course these two methods are applicable for the other 4 levels: **INFO**, **WARN**, **ERROR** and **FATAL**.
@@ -71,3 +71,44 @@ To date four implementations are provided with Rozenn:
7171
* **org.rozenn.layout.FlashInspectorLayout** – Messages are sent to FlashInspector application developped by `Pablo Constantini <http://www.luminicbox.com/>`_.
7272
* **org.rozenn.layout.FireBugLayout** – Messages are sent to the inevitable Firefox plugin `FireBug <http://getfirebug.com/>`_. Of course your SWF to be played with the browser, the messages appear in the module "Console" plugin.
7373

74+
Formatting messages
75+
-------------------
76+
Rozenn can format the logging messages. This action takes place before they are sent to a layout. The formatting of messages is done by classes implementing the interface **org.rozenn.formatter.IFormatter**. These objects are associated with the layouts.
77+
78+
Rozenn offers two formatters:
79+
* **org.rozenn.formatter.SimpleFormatter** – A formatter very simple: it passes the message body to layout as that is.
80+
* **org.rozenn.formatter.PatternFormatter** – This formatter is more advanced. Its constructor takes a pattern that will define the form that will take a message once sent to the layout.
81+
82+
Example for pattern **%L [%C] %M** :
83+
84+
::
85+
86+
var logger : Logger = Logger.getLogger("root");
87+
logger.debug("Message A");
88+
logger.warn("Message B");
89+
90+
result :
91+
92+
::
93+
94+
DEBUG [root] Message A
95+
WARN [root] Message B
96+
97+
Table summary tags:
98+
+--------+-------------------------------------------------------------------------------------------------------------------------------------+
99+
| Tag | Result |
100+
+========+=====================================================================================================================================+
101+
| **%C** | The name of the sender of the message log. |
102+
+--------+-------------------------------------------------------------------------------------------------------------------------------------+
103+
| **%D** | The issue date of the message. |
104+
| | This tag is a bit special because it accepts an option: **%D{dd/MM/yyyy – HH:mm:ss}** |
105+
| | This option lets you specify as the date will be displayed. This option is analyzed by the class **org.rozenn.utils.DateFormatter** |
106+
| | I suggest you take a look at the documentation of the latter. |
107+
+--------+-------------------------------------------------------------------------------------------------------------------------------------+
108+
| **%L** | The message level |
109+
+--------+-------------------------------------------------------------------------------------------------------------------------------------+
110+
| **%M** | The message body |
111+
+--------+-------------------------------------------------------------------------------------------------------------------------------------+
112+
113+
114+

0 commit comments

Comments
 (0)