LSSTApplications
10.0+286,10.0+36,10.0+46,10.0-2-g4f67435,10.1+152,10.1+37,11.0,11.0+1,11.0-1-g47edd16,11.0-1-g60db491,11.0-1-g7418c06,11.0-2-g04d2804,11.0-2-g68503cd,11.0-2-g818369d,11.0-2-gb8b8ce7
LSSTDataManagementBasePackage
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
home
lsstsw
stack
Linux64
pex_logging
11.0+1
src
DualLog.cc
Go to the documentation of this file.
1
/*
2
* LSST Data Management System
3
* Copyright 2008, 2009, 2010 LSST Corporation.
4
*
5
* This product includes software developed by the
6
* LSST Project (http://www.lsst.org/).
7
*
8
* This program is free software: you can redistribute it and/or modify
9
* it under the terms of the GNU General Public License as published by
10
* the Free Software Foundation, either version 3 of the License, or
11
* (at your option) any later version.
12
*
13
* This program is distributed in the hope that it will be useful,
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
* GNU General Public License for more details.
17
*
18
* You should have received a copy of the LSST License Statement and
19
* the GNU General Public License along with this program. If not,
20
* see <http://www.lsstcorp.org/LegalNotices/>.
21
*/
22
27
#include "
lsst/pex/logging/DualLog.h
"
28
29
#include <iostream>
30
#include <boost/shared_ptr.hpp>
31
32
namespace
lsst {
33
namespace
pex {
34
namespace
logging {
35
36
//@cond
37
38
using namespace
std;
39
using
boost::shared_ptr;
40
using
lsst::daf::base::PropertySet
;
41
43
// DualLog
45
46
/*
47
* create a Log that will write messages to a given file
48
* @param filename the name of the file to send messages to. It will
49
* be opened in append mode.
50
* @param filethresh the importance threshold to set for the log file
51
* @param screenthresh the importance threshold to set for messages going
52
* to the screen.
53
* @param screenVerbose if true, all message data properties will be printed
54
* to the screen. If false, only the Log name
55
* ("LOG") and the text comment ("COMMENT") will be
56
* printed.
57
*/
58
DualLog::DualLog
(
const
PropertySet
& preamble,
const
string
& filename,
59
int
filethresh,
int
screenthresh,
bool
screenVerbose)
60
: ScreenLog(preamble, screenVerbose, screenthresh)
61
{
62
_init(filename, filethresh);
63
}
64
65
DualLog::DualLog
(
const
string
& filename,
66
int
filethresh,
int
screenthresh,
bool
screenVerbose)
67
: ScreenLog(screenVerbose, screenthresh)
68
{
69
_init(filename, filethresh);
70
}
71
72
void
DualLog::_init
(
const
string
& filename,
int
filethresh) {
73
74
// the DualLog destructor will close & destroy this.
75
fstrm
=
new
ofstream(filename.c_str(), ios_base::app);
76
77
shared_ptr<LogFormatter> fmtr(
new
NetLoggerFormatter());
78
79
// note that the shared_ptr held by LogDestination list will
80
// handle the deletion of this pointer.
81
_file
=
new
LogDestination(
fstrm
, fmtr, filethresh);
82
shared_ptr<LogDestination> dest(
_file
);
83
_destinations
.push_back( dest );
84
}
85
86
DualLog::~DualLog
() {
87
fstrm
->close();
88
delete
fstrm
;
89
}
90
91
void
DualLog::createDefaultLog
(
const
PropertySet
& preamble,
92
const
string
& filename,
int
filethresh,
93
int
screenthresh,
bool
screenVerbose)
94
{
95
Log::setDefaultLog
(
new
DualLog
(preamble, filename, filethresh,
96
screenthresh, screenVerbose));
97
}
98
99
void
DualLog::createDefaultLog
(
const
string
& filename,
int
filethresh,
100
int
screenthresh,
bool
screenVerbose)
101
{
102
Log::setDefaultLog
(
new
DualLog
(filename, filethresh,
103
screenthresh, screenVerbose));
104
}
105
106
//@endcond
107
}}}
// end lsst::pex::logging
108
DualLog.h
lsst::pex::logging::Log::setDefaultLog
static void setDefaultLog(Log *deflog)
lsst::pex::logging::DualLog::fstrm
std::ofstream * fstrm
Definition:
DualLog.h:163
PropertySet
lsst::daf::base::PropertySet PropertySet
Definition:
Wcs.cc:58
lsst::pex::logging::DualLog::_init
void _init(const std::string &filename, int filethresh)
lsst::pex::logging::DualLog::createDefaultLog
static void createDefaultLog(const lsst::daf::base::PropertySet &preamble, const std::string &filename, int filethresh=Log::INHERIT_THRESHOLD, int screenthresh=0, bool screenVerbose=false)
lsst::pex::logging::DualLog::DualLog
DualLog(const lsst::daf::base::PropertySet &preamble, const std::string &filename, int filethresh=0, int screenthresh=0, bool screenVerbose=false)
lsst::daf::base::PropertySet
Class for storing generic metadata.
Definition:
PropertySet.h:82
lsst::pex::logging::Log::_destinations
std::list< boost::shared_ptr< LogDestination > > _destinations
Definition:
Log.h:684
lsst::pex::logging::DualLog::~DualLog
virtual ~DualLog()
lsst::pex::logging::DualLog::_file
LogDestination * _file
Definition:
DualLog.h:162
Generated on Thu Sep 24 2015 02:29:23 for LSSTApplications by
1.8.5