File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2323import java .util .Date ;
2424import java .util .regex .Pattern ;
2525import java .nio .ByteBuffer ;
26-
26+ import java . util . logging .*;
2727
2828/**
2929 * Deserializes a string from the database into a <code>DBObject</code>.
@@ -129,11 +129,11 @@ private DBObject _create( String path ){
129129 return (DBObject )c .newInstance ();
130130 }
131131 catch ( InstantiationException ie ){
132- ie . printStackTrace ( );
132+ LOGGER . log ( Level . FINE , "can't create a: " + c , ie );
133133 throw new MongoInternalException ( "can't instantiate a : " + c , ie );
134134 }
135135 catch ( IllegalAccessException iae ){
136- iae . printStackTrace ( );
136+ LOGGER . log ( Level . FINE , "can't create a: " + c , iae );
137137 throw new MongoInternalException ( "can't instantiate a : " + c , iae );
138138 }
139139 }
Original file line number Diff line number Diff line change 2222import java .nio .charset .*;
2323import java .util .regex .Pattern ;
2424import java .util .*;
25+ import java .util .logging .*;
2526
2627/**
2728 * Handles byte functions for <code>ByteEncoder</code> and <code>ByteDecoder</code>.
2829 */
2930public class Bytes {
30-
31+
32+ static Logger LOGGER = Logger .getLogger ( "com.mongodb" );
33+
3134 static final boolean D = Boolean .getBoolean ( "DEBUG.DB" );
3235
36+ static {
37+ if ( D )
38+ LOGGER .setLevel ( Level .ALL );
39+ else
40+ LOGGER .setLevel ( Level .WARNING );
41+ }
42+
3343 /** Little-endian */
3444 public static final ByteOrder ORDER = ByteOrder .LITTLE_ENDIAN ;
3545
Original file line number Diff line number Diff line change 2020
2121import java .nio .*;
2222import java .util .*;
23+ import java .util .logging .*;
2324
2425import com .mongodb .util .*;
2526
@@ -344,7 +345,7 @@ void _cleanCursors()
344345 killCursors ( l );
345346 }
346347 catch ( Throwable t ){
347- t . printStackTrace ( );
348+ Bytes . LOGGER . log ( Level . WARNING , "can't clean cursors" , t );
348349 _deadCursorIds .addAll ( l );
349350 }
350351 }
Original file line number Diff line number Diff line change @@ -144,8 +144,8 @@ void _open()
144144 }
145145 catch ( IOException ioe ){
146146// TODO - erh to fix lastError = new IOException( "couldn't connect to [" + _addr + "] bc:" + lastError , lastError );
147- lastError = new IOException ( "couldn't connect to [" + _addr + "] bc:" + ioe );
148- _logger .log ( Level .SEVERE , "connect fail to : " + _addr , ioe );
147+ lastError = new IOException ( "couldn't connect to [" + _addr + "] bc:" + ioe , ioe );
148+ _logger .log ( Level .INFO , "connect fail to : " + _addr , ioe );
149149 }
150150
151151 if ( _pool != null && ! _pool ._everWorked )
@@ -202,5 +202,5 @@ protected void finalize(){
202202 private SocketChannel _sock ;
203203
204204
205- private static Logger _rootLogger = Logger .getLogger ( "db .port" );
205+ private static Logger _rootLogger = Logger .getLogger ( "com.mongodb .port" );
206206}
Original file line number Diff line number Diff line change 2424import java .net .*;
2525import java .util .*;
2626import java .util .concurrent .*;
27+ import java .util .logging .*;
2728
2829class DBPortPool extends SimplePool <DBPort > {
2930
@@ -102,8 +103,7 @@ void gotError( Exception e ){
102103 return ;
103104 }
104105
105- System .out .println ( "emptying DBPortPool b/c of error" );
106- e .printStackTrace ();
106+ Bytes .LOGGER .log ( Level .INFO , "emptying DBPortPool b/c of error" , e );
107107 clear ();
108108 }
109109
Original file line number Diff line number Diff line change 2626
2727public class DBTCP extends DBMessageLayer {
2828
29- static Logger _logger = Logger .getLogger ( "DBTCP " );
29+ static Logger _logger = Logger .getLogger ( Bytes . LOGGER . getName () + ".tcp " );
3030 static Logger _createLogger = Logger .getLogger ( _logger .getName () + ".connect" );
3131
3232 public DBTCP ( DBAddress addr )
You can’t perform that action at this time.
0 commit comments