 |
Changeset 2304
- Timestamp:
- 06/14/07 03:19:48
(1 year ago)
- Author:
- kris
- Message:
had to rename Layout to be EventLayout?, in order to avoid conflict with tango.text.convert.Layout
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r1121 |
r2304 |
|
| 14 | 14 | |
|---|
| 15 | 15 | public import tango.util.log.Event, |
|---|
| 16 | | tango.util.log.Layout; |
|---|
| | 16 | tango.util.log.EventLayout; |
|---|
| 17 | 17 | |
|---|
| 18 | 18 | /******************************************************************************* |
|---|
| … | … | |
| 21 | 21 | emitting messages sent to a particular logger. There may be more |
|---|
| 22 | 22 | than one appender attached to any logger. The actual message is |
|---|
| 23 | | constructed by another class known as a Layout. |
|---|
| | 23 | constructed by another class known as an EventLayout. |
|---|
| 24 | 24 | |
|---|
| 25 | 25 | *******************************************************************************/ |
|---|
| … | … | |
| 30 | 30 | |
|---|
| 31 | 31 | private Appender next; |
|---|
| 32 | | private Layout layout; |
|---|
| | 32 | private EventLayout layout; |
|---|
| 33 | 33 | |
|---|
| 34 | 34 | /*********************************************************************** |
|---|
| … | … | |
| 105 | 105 | ***********************************************************************/ |
|---|
| 106 | 106 | |
|---|
| 107 | | void setLayout (Layout layout) |
|---|
| | 107 | void setLayout (EventLayout layout) |
|---|
| 108 | 108 | { |
|---|
| 109 | 109 | if (layout) |
|---|
| … | … | |
| 117 | 117 | ***********************************************************************/ |
|---|
| 118 | 118 | |
|---|
| 119 | | Layout getLayout () |
|---|
| | 119 | EventLayout getLayout () |
|---|
| 120 | 120 | { |
|---|
| 121 | 121 | return layout; |
|---|
| r1121 |
r2304 |
|
| 14 | 14 | |
|---|
| 15 | 15 | private import tango.util.log.Log, |
|---|
| 16 | | tango.util.log.Layout, |
|---|
| | 16 | tango.util.log.EventLayout, |
|---|
| 17 | 17 | tango.util.log.ConsoleAppender; |
|---|
| 18 | 18 | |
|---|
| r1121 |
r2304 |
|
| 34 | 34 | ***********************************************************************/ |
|---|
| 35 | 35 | |
|---|
| 36 | | this (Layout layout = null) |
|---|
| | 36 | this (EventLayout layout = null) |
|---|
| 37 | 37 | { |
|---|
| 38 | 38 | // Get a unique fingerprint for this class |
|---|
| … | … | |
| 72 | 72 | synchronized void append (Event event) |
|---|
| 73 | 73 | { |
|---|
| 74 | | Layout layout = getLayout; |
|---|
| 75 | | Cerr.append (layout.header (event)); |
|---|
| 76 | | Cerr.append (layout.content (event)); |
|---|
| 77 | | Cerr.append (layout.footer (event)); |
|---|
| | 74 | auto layout = getLayout; |
|---|
| | 75 | Cerr (layout.header (event)); |
|---|
| | 76 | Cerr (layout.content (event)); |
|---|
| | 77 | Cerr (layout.footer (event)); |
|---|
| 78 | 78 | Cerr.newline; |
|---|
| 79 | 79 | } |
|---|
| r2164 |
r2304 |
|
| 14 | 14 | |
|---|
| 15 | 15 | private import tango.util.log.Event, |
|---|
| 16 | | tango.util.log.Layout; |
|---|
| | 16 | tango.util.log.EventLayout; |
|---|
| 17 | 17 | |
|---|
| 18 | 18 | private import tango.text.Util; |
|---|
| … | … | |
| 29 | 29 | *******************************************************************************/ |
|---|
| 30 | 30 | |
|---|
| 31 | | public class DateLayout : Layout |
|---|
| | 31 | public class DateLayout : EventLayout |
|---|
| 32 | 32 | { |
|---|
| 33 | 33 | private bool localTime; |
|---|
| r2164 |
r2304 |
|
| 39 | 39 | Note that Event instances are maintained in a freelist rather than |
|---|
| 40 | 40 | being allocated each time, and they include a scratchpad area for |
|---|
| 41 | | Layout formatters to use. |
|---|
| | 41 | EventLayout formatters to use. |
|---|
| 42 | 42 | |
|---|
| 43 | 43 | *******************************************************************************/ |
|---|
| r1634 |
r2304 |
|
| 11 | 11 | *******************************************************************************/ |
|---|
| 12 | 12 | |
|---|
| 13 | | module tango.util.log.Layout; |
|---|
| | 13 | module tango.util.log.EventLayout; |
|---|
| 14 | 14 | |
|---|
| 15 | 15 | private import tango.util.log.Event; |
|---|
| … | … | |
| 19 | 19 | /******************************************************************************* |
|---|
| 20 | 20 | |
|---|
| 21 | | Base class for all Layout instances |
|---|
| | 21 | Base class for all logging layout instances |
|---|
| 22 | 22 | |
|---|
| 23 | 23 | *******************************************************************************/ |
|---|
| 24 | 24 | |
|---|
| 25 | | public class Layout |
|---|
| | 25 | public class EventLayout |
|---|
| 26 | 26 | { |
|---|
| 27 | 27 | /*********************************************************************** |
|---|
| … | … | |
| 85 | 85 | *******************************************************************************/ |
|---|
| 86 | 86 | |
|---|
| 87 | | public class SpartanLayout : Layout |
|---|
| | 87 | public class SpartanLayout : EventLayout |
|---|
| 88 | 88 | { |
|---|
| 89 | 89 | /*********************************************************************** |
|---|
| … | … | |
| 107 | 107 | *******************************************************************************/ |
|---|
| 108 | 108 | |
|---|
| 109 | | public class SimpleLayout : Layout |
|---|
| | 109 | public class SimpleLayout : EventLayout |
|---|
| 110 | 110 | { |
|---|
| 111 | 111 | /*********************************************************************** |
|---|
| … | … | |
| 131 | 131 | *******************************************************************************/ |
|---|
| 132 | 132 | |
|---|
| 133 | | public class SimpleTimerLayout : Layout |
|---|
| | 133 | public class SimpleTimerLayout : EventLayout |
|---|
| 134 | 134 | { |
|---|
| 135 | 135 | /*********************************************************************** |
|---|
| r1211 |
r2304 |
|
| 50 | 50 | ***********************************************************************/ |
|---|
| 51 | 51 | |
|---|
| 52 | | this (FilePath fp, Layout layout = null) |
|---|
| | 52 | this (FilePath fp, EventLayout layout = null) |
|---|
| 53 | 53 | { |
|---|
| 54 | 54 | // Get a unique fingerprint for this instance |
|---|
| … | … | |
| 62 | 62 | |
|---|
| 63 | 63 | Create a basic FileAppender to a file with the specified |
|---|
| 64 | | path, and with the given Layout |
|---|
| | 64 | path, and with the given EventLayout |
|---|
| 65 | 65 | |
|---|
| 66 | 66 | ***********************************************************************/ |
|---|
| 67 | 67 | |
|---|
| 68 | | this (char[] fp, Layout layout = null) |
|---|
| | 68 | this (char[] fp, EventLayout layout = null) |
|---|
| 69 | 69 | { |
|---|
| 70 | 70 | this (new FilePath (fp), layout); |
|---|
| … | … | |
| 125 | 125 | synchronized void append (Event event) |
|---|
| 126 | 126 | { |
|---|
| 127 | | Layout layout = getLayout; |
|---|
| | 127 | auto layout = getLayout; |
|---|
| 128 | 128 | buffer.append (layout.header (event)); |
|---|
| 129 | 129 | buffer.append (layout.content (event)); |
|---|
| r1634 |
r2304 |
|
| 16 | 16 | |
|---|
| 17 | 17 | private import tango.util.log.Event, |
|---|
| 18 | | tango.util.log.Layout; |
|---|
| | 18 | tango.util.log.EventLayout; |
|---|
| 19 | 19 | |
|---|
| 20 | 20 | /******************************************************************************* |
|---|
| … | … | |
| 24 | 24 | *******************************************************************************/ |
|---|
| 25 | 25 | |
|---|
| 26 | | public class Log4Layout : Layout |
|---|
| | 26 | public class Log4Layout : EventLayout |
|---|
| 27 | 27 | { |
|---|
| 28 | 28 | /*********************************************************************** |
|---|
| r2091 |
r2304 |
|
| 67 | 67 | --- |
|---|
| 68 | 68 | |
|---|
| 69 | | You may also need to use one of the various Layout & Appender |
|---|
| | 69 | You may also need to use one of the various layout & appender |
|---|
| 70 | 70 | implementations to support your exact rendering needs. |
|---|
| 71 | 71 | |
|---|
| r1121 |
r2304 |
|
| 36 | 36 | /*********************************************************************** |
|---|
| 37 | 37 | |
|---|
| 38 | | Create with the given Layout and server address |
|---|
| | 38 | Create with the given layout and server address |
|---|
| 39 | 39 | |
|---|
| 40 | 40 | ***********************************************************************/ |
|---|
| 41 | 41 | |
|---|
| 42 | | this (InternetAddress server, char[] from, char[] to, char[] subj, Layout layout = null) |
|---|
| | 42 | this (InternetAddress server, char[] from, char[] to, char[] subj, EventLayout layout = null) |
|---|
| 43 | 43 | { |
|---|
| 44 | 44 | setLayout (layout); |
|---|
| r1121 |
r2304 |
|
| 44 | 44 | ***********************************************************************/ |
|---|
| 45 | 45 | |
|---|
| 46 | | this (Layout layout) |
|---|
| | 46 | this (EventLayout layout) |
|---|
| 47 | 47 | { |
|---|
| 48 | 48 | setLayout (layout); |
|---|
| … | … | |
| 79 | 79 | void append (Event event) |
|---|
| 80 | 80 | { |
|---|
| 81 | | Layout layout = getLayout; |
|---|
| | 81 | auto layout = getLayout; |
|---|
| 82 | 82 | layout.header (event); |
|---|
| 83 | 83 | layout.content (event); |
|---|
| r1598 |
r2304 |
|
| 18 | 18 | private import tango.io.FilePath; |
|---|
| 19 | 19 | |
|---|
| 20 | | private import tango.util.log.Log, |
|---|
| 21 | | tango.util.log.Layout, |
|---|
| 22 | | tango.util.log.DateLayout, |
|---|
| 23 | | tango.util.log.Configurator, |
|---|
| 24 | | tango.util.log.ConsoleAppender; |
|---|
| | 20 | private import tango.util.log.Log; |
|---|
| 25 | 21 | |
|---|
| 26 | 22 | private import tango.util.log.model.ILevel; |
|---|
| r2131 |
r2304 |
|
| 47 | 47 | ***********************************************************************/ |
|---|
| 48 | 48 | |
|---|
| 49 | | this (char[] path, int count, ulong maxSize, Layout layout = null) |
|---|
| | 49 | this (char[] path, int count, ulong maxSize, EventLayout layout = null) |
|---|
| 50 | 50 | { |
|---|
| 51 | 51 | assert (path); |
|---|
| … | … | |
| 129 | 129 | |
|---|
| 130 | 130 | // write log message and flush it |
|---|
| 131 | | Layout layout = getLayout; |
|---|
| | 131 | auto layout = getLayout (); |
|---|
| 132 | 132 | msg = layout.header (event); |
|---|
| 133 | 133 | fileSize += msg.length; |
|---|
| r2002 |
r2304 |
|
| 41 | 41 | ***********************************************************************/ |
|---|
| 42 | 42 | |
|---|
| 43 | | this (InternetAddress address, Layout layout = null) |
|---|
| | 43 | this (InternetAddress address, EventLayout layout = null) |
|---|
| 44 | 44 | { |
|---|
| 45 | 45 | setLayout (layout); |
|---|
| … | … | |
| 87 | 87 | void append (Event event) |
|---|
| 88 | 88 | { |
|---|
| 89 | | auto layout = getLayout; |
|---|
| | 89 | auto layout = getLayout(); |
|---|
| 90 | 90 | |
|---|
| 91 | 91 | if (buffer) |
|---|
Download in other formats:
|
 |
 |
|
 |
Copyright © 2006-2008 Tango. All Rights Reserved. | Page Width:
Static or
Dynamic