public
Description: Phusion Passenger (mod_rails)
Homepage: http://www.modrails.com/
Clone URL: git://github.com/FooBarWidget/passenger.git
Search Repo:
Click here to lend your support to: passenger and make a donation at www.pledgie.com !
Make debugging code more fault-tolerant.
FooBarWidget (author)
Fri Feb 01 02:15:01 -0800 2008
commit  0df1814d5800bb379c4e405989bb70b7b104d3d6
tree    fa6546a8f1d2f697db56d7825ae358a9ffa2093b
parent  598ebedf9003a7310bb22ad09d18ec03823b067f
...
12
13
14
15
 
 
 
 
 
 
16
17
18
...
12
13
14
 
15
16
17
18
19
20
21
22
23
0
@@ -12,7 +12,12 @@
0
 initDebugging(const char *logFile) {
0
   #ifdef PASSENGER_DEBUG
0
     if (logFile != NULL) {
0
- _debugStream = new ofstream(logFile, ios_base::out | ios_base::app);
0
+ ostream *stream = new ofstream(logFile, ios_base::out | ios_base::app);
0
+ if (stream->fail()) {
0
+ delete stream;
0
+ } else {
0
+ _debugStream = stream;
0
+ }
0
     } else {
0
       _debugStream = &cerr;
0
     }
...
6
7
8
9
10
11
 
 
 
 
 
 
 
 
12
13
14
...
6
7
8
 
 
 
9
10
11
12
13
14
15
16
17
18
19
0
@@ -6,9 +6,14 @@
0
 namespace Passenger {
0
 
0
 #ifdef PASSENGER_DEBUG
0
- #define P_DEBUG(expr) *Passenger::_debugStream << \
0
- "[" << __FILE__ << ":" << __LINE__ << "] " << \
0
- expr << std::endl
0
+ #define P_DEBUG(expr) \
0
+ do { \
0
+ if (Passenger::_debugStream != 0) { \
0
+ *Passenger::_debugStream << \
0
+ "[" << __FILE__ << ":" << __LINE__ << "] " << \
0
+ expr << std::endl; \
0
+ } \
0
+ } while (false)
0
 #else
0
   #define P_DEBUG(expr) do { /* nothing */ } while (false)
0
 #endif

Comments

    No one has commented yet.