Ignore:
Timestamp:
28/03/2008 22:18:44 (4 years ago)
Author:
chris
Message:

Improve logging with macros that consistently output strerror(errno) and
errno, replacing almost all use of strerror() in the main code.

Log a more detailed error message before throwing an exception for some
more system call failures.

Make FileStream? store its filename on all platforms, not just Windows.

Wrap some long lines at less than 80 characters to improve readability.

Fix some minor violations of coding standard (white space) and a typo
in a comment.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • box/trunk/lib/server/Daemon.cpp

    r2110 r2115  
    466466                        if(::setsid() == -1) 
    467467                        { 
    468                                 BOX_ERROR("Failed to setsid(): " <<  
    469                                         strerror(errno)); 
     468                                BOX_LOG_SYS_ERROR("Failed to setsid()"); 
    470469                                THROW_EXCEPTION(ServerException, DaemoniseFailed) 
    471470                        } 
     
    476475                        case -1: 
    477476                                // error 
     477                                BOX_LOG_SYS_ERROR("Failed to fork() a child"); 
    478478                                THROW_EXCEPTION(ServerException, DaemoniseFailed) 
    479479                                break; 
     
    498498                sa.sa_handler = SignalHandler; 
    499499                sa.sa_flags = 0; 
    500                 sigemptyset(&sa.sa_mask);               // macro 
    501                 if(::sigaction(SIGHUP, &sa, NULL) != 0 || ::sigaction(SIGTERM, &sa, NULL) != 0) 
    502                 { 
     500                sigemptyset(&sa.sa_mask); // macro 
     501                if(::sigaction(SIGHUP, &sa, NULL) != 0 || 
     502                        ::sigaction(SIGTERM, &sa, NULL) != 0) 
     503                { 
     504                        BOX_LOG_SYS_ERROR("Failed to set signal handlers"); 
    503505                        THROW_EXCEPTION(ServerException, DaemoniseFailed) 
    504506                } 
     
    516518                if(::write(pidFile, pid, pidsize) != pidsize) 
    517519                { 
    518                         BOX_FATAL("can't write pid file"); 
     520                        BOX_LOG_SYS_FATAL("Failed to write PID file: " << 
     521                                pidFileName); 
    519522                        THROW_EXCEPTION(ServerException, DaemoniseFailed) 
    520523                } 
     
    545548                        if(devnull == -1) 
    546549                        { 
     550                                BOX_LOG_SYS_ERROR("Failed to open /dev/null"); 
    547551                                THROW_EXCEPTION(CommonException, OSFileError); 
    548552                        } 
     
    891895                        return 0; 
    892896                } 
     897                BOX_LOG_SYS_ERROR("Failed to stat configuration file: " << 
     898                        GetConfigFileName()); 
    893899                THROW_EXCEPTION(CommonException, OSFileError) 
    894900        } 
Note: See TracChangeset for help on using the changeset viewer.