Subversion Repository Public Repository

litesoft

Diff Revisions 947 vs 948 for /trunk/Java/GWT/Client/src/org/litesoft/GWT/client/logging/BrowserAsLogSyncFactory.java

Diff revisions: vs.
  @@ -8,46 +8,35 @@
8 8
9 9 import com.google.gwt.user.client.*;
10 10
11 - public class BrowserAsLogSyncFactory implements ProxyLoggerFactory
12 - {
11 + public class BrowserAsLogSyncFactory implements ProxyLoggerFactory {
13 12 public static final int MAX_LOG_LINES_TO_CACHE = 100;
14 13
15 14 public static final BrowserAsLogSyncFactory INSTANCE = new BrowserAsLogSyncFactory();
16 15
17 - public static final Command COMMAND = new Command()
18 - {
16 + public static final Command COMMAND = new Command() {
19 17 @Override
20 - public void execute()
21 - {
18 + public void execute() {
22 19 BrowserAsLogSyncFactory.open();
23 20 }
24 21 };
25 22
26 - private BrowserAsLogSyncFactory()
27 - {
23 + private BrowserAsLogSyncFactory() {
28 24 }
29 25
30 - public static void open()
31 - {
32 - if ( (sOpen = openLogSyncBrowser( UtilsGwt.CHROMELESS_SCROLLED, CLIENT_LOGGING_HTML )) )
33 - {
26 + public static void open() {
27 + if ( (sOpen = openLogSyncBrowser( UtilsGwt.CHROMELESS_SCROLLED, CLIENT_LOGGING_HTML )) ) {
34 28 sOpen = addToLogSyncBrowser( "" );
35 - while ( sOpen && sSavedLines.hasLines() )
36 - {
37 - if ( (sOpen = addToLogSyncBrowser( sSavedLines.peekLine() )) )
38 - {
29 + while ( sOpen && sSavedLines.hasLines() ) {
30 + if ( (sOpen = addToLogSyncBrowser( sSavedLines.peekLine() )) ) {
39 31 sSavedLines.dropLine();
40 32 }
41 33 }
42 34 }
43 35 }
44 36
45 - public static void log( String pText )
46 - {
47 - if ( sOpen )
48 - {
49 - if ( addToLogSyncBrowser( pText ) )
50 - {
37 + public static void log( String pText ) {
38 + if ( sOpen ) {
39 + if ( addToLogSyncBrowser( pText ) ) {
51 40 return;
52 41 }
53 42 sOpen = false;
  @@ -89,73 +78,57 @@
89 78 return false;
90 79 }-*/;
91 80
92 - private static class LogLinkedList
93 - {
81 + private static class LogLinkedList {
94 82 private int mNodes = 0;
95 83 private Node mHead = null;
96 84 private Node mTail = null;
97 85
98 - public boolean hasLines()
99 - {
86 + public boolean hasLines() {
100 87 return (mNodes != 0);
101 88 }
102 89
103 - public String peekLine()
104 - {
90 + public String peekLine() {
105 91 return (mHead != null) ? mHead.getText() : null;
106 92 }
107 93
108 - public void dropLine()
109 - {
110 - if ( hasLines() )
111 - {
94 + public void dropLine() {
95 + if ( hasLines() ) {
112 96 mNodes--;
113 - if ( null == (mHead = mHead.getNext()) )
114 - {
97 + if ( null == (mHead = mHead.getNext()) ) {
115 98 mTail = null;
116 99 }
117 100 }
118 101 }
119 102
120 - public void add( String pText )
121 - {
122 - if ( mTail == null )
123 - {
103 + public void add( String pText ) {
104 + if ( mTail == null ) {
124 105 mHead = mTail = new Node( pText );
125 - }
126 - else
127 - {
106 + } else {
128 107 mTail = mTail.add( pText );
129 108 }
130 - if ( ++mNodes > MAX_LOG_LINES_TO_CACHE )
131 - {
109 + if ( ++mNodes > MAX_LOG_LINES_TO_CACHE ) {
132 110 mNodes--;
133 111 mHead = mHead.getNext();
134 112 }
135 113 }
136 114
137 - private static class Node
138 - {
115 + private static class Node {
139 116 private Node mNext = null;
140 117 private String mText;
141 118
142 - public Node( String pText )
143 - {
119 + public Node( String pText ) {
144 120 mText = pText;
145 121 }
146 122
147 - public Node getNext()
148 - {
123 + public Node getNext() {
149 124 return mNext;
150 125 }
151 126
152 - public String getText()
153 - {
127 + public String getText() {
154 128 return mText;
155 129 }
156 130
157 - public Node add( String pText )
158 - {
131 + public Node add( String pText ) {
159 132 return mNext = new Node( pText );
160 133 }
161 134 }
  @@ -174,31 +147,28 @@
174 147 "}\n" + //
175 148 "</script></head><body style='margin:0; padding:0;'>" + //
176 149 "<center>Client Side Logging<br>" + //
177 - "- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -" + "</center></body></html>";
150 + "- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - " +
151 + "- - - - - -" +
152 + "</center></body></html>";
178 153
179 154 @Override
180 - public ImplLoggerAdapter createImplLoggerAdapter( int pLevel, String pClassname )
181 - {
155 + public ImplLoggerAdapter createImplLoggerAdapter( int pLevel, String pClassname ) {
182 156 return new Logger( pLevel, pClassname );
183 157 }
184 158
185 - private static class Logger extends SystemOutLoggerAdapter
186 - {
187 - public Logger( int pLevel, String pClassname )
188 - {
159 + private static class Logger extends SystemOutLoggerAdapter {
160 + public Logger( int pLevel, String pClassname ) {
189 161 super( LoggerLevel.LEVELS[pLevel], pClassname );
190 162 }
191 163
192 164 @Override
193 - protected void println( Throwable pThrowable )
194 - {
165 + protected void println( Throwable pThrowable ) {
195 166 super.println( pThrowable );
196 167 BrowserAsLogSyncFactory.log( Throwables.printStackTraceToString( pThrowable ) );
197 168 }
198 169
199 170 @Override
200 - protected void println( boolean pHasThrowable, String pText )
201 - {
171 + protected void println( boolean pHasThrowable, String pText ) {
202 172 super.println( pHasThrowable, pText );
203 173 BrowserAsLogSyncFactory.log( pText );
204 174 }