NCBI C++ ToolKit
email_diag_handler.cpp
Go to the documentation of this file.

Go to the SVN repository for this file.

00001 /* $Id: email_diag_handler.cpp 39718 2008-10-16 18:19:55Z lavr $
00002  * ===========================================================================
00003  *
00004  *                            PUBLIC DOMAIN NOTICE
00005  *               National Center for Biotechnology Information
00006  *
00007  *  This software/database is a "United States Government Work" under the
00008  *  terms of the United States Copyright Act.  It was written as part of
00009  *  the author's official duties as a United States Government employee and
00010  *  thus cannot be copyrighted.  This software/database is freely available
00011  *  to the public for use. The National Library of Medicine and the U.S.
00012  *  Government have not placed any restriction on its use or reproduction.
00013  *
00014  *  Although all reasonable efforts have been taken to ensure the accuracy
00015  *  and reliability of the software and data, the NLM and the U.S.
00016  *  Government do not and cannot warrant the performance or results that
00017  *  may be obtained by using this software or data. The NLM and the U.S.
00018  *  Government disclaim all warranties, express or implied, including
00019  *  warranties of performance, merchantability or fitness for any particular
00020  *  purpose.
00021  *
00022  *  Please cite the author in any work or product based on this material.
00023  *
00024  * ===========================================================================
00025  *
00026  * Author:  Aaron Ucko
00027  *
00028  * File Description:
00029  *   Diagnostic handler for e-mailing logs.
00030  *
00031  */
00032 
00033 #include <ncbi_pch.hpp>
00034 #include <connect/email_diag_handler.hpp>
00035 #include <connect/ncbi_sendmail.h>
00036 
00037 
00038 // (BEGIN_NCBI_SCOPE must be followed by END_NCBI_SCOPE later in this file)
00039 BEGIN_NCBI_SCOPE
00040 
00041 
00042 CEmailDiagHandler::~CEmailDiagHandler(void)
00043 {
00044     CNcbiOstrstream* oss = dynamic_cast<CNcbiOstrstream*>(m_Stream);
00045     string body = CNcbiOstrstreamToString(*oss);
00046     if ( !body.empty() ) {
00047         const char* msg = CORE_SendMail(m_To.c_str(), m_Sub.c_str(), body.c_str());
00048         if (msg) {
00049             // Need to report by other means, obviously...
00050             NcbiCerr << msg << endl;
00051         }
00052     }
00053     delete m_Stream;
00054 }
00055 
00056 
00057 // (END_NCBI_SCOPE must be preceded by BEGIN_NCBI_SCOPE)
00058 END_NCBI_SCOPE
Modified on Thu Dec 25 11:40:57 2014 by modify_doxy.py rev. 426318