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
Public Member Functions | Protected Attributes | List of all members
lsst::pex::logging::FileDestination Class Reference

a LogDestination represented by a file. More...

#include <FileDestination.h>

Inheritance diagram for lsst::pex::logging::FileDestination:
lsst::pex::logging::LogDestination

Public Member Functions

virtual ~FileDestination ()
 
const boost::filesystem::path & getPath () const
 
 FileDestination (const std::string &filepath, const boost::shared_ptr< LogFormatter > &formatter, int threshold=threshold::PASS_ALL, bool truncate=false)
 
 FileDestination (const char *filepath, const boost::shared_ptr< LogFormatter > &formatter, int threshold=threshold::PASS_ALL, bool truncate=false)
 
 FileDestination (const boost::filesystem::path &filepath, const boost::shared_ptr< LogFormatter > &formatter, int threshold=threshold::PASS_ALL, bool truncate=false)
 
 FileDestination (const boost::filesystem::path &filepath, bool verbose=false, int threshold=threshold::PASS_ALL, bool truncate=false)
 
 FileDestination (const std::string &filepath, bool verbose=false, int threshold=threshold::PASS_ALL, bool truncate=false)
 
 FileDestination (const char *filepath, bool verbose=false, int threshold=threshold::PASS_ALL, bool truncate=false)
 
- Public Member Functions inherited from lsst::pex::logging::LogDestination
 LogDestination (std::ostream *strm, const boost::shared_ptr< LogFormatter > &formatter, int threshold=threshold::PASS_ALL)
 create a destination with a threshold. More...
 
 LogDestination (const LogDestination &that)
 
virtual ~LogDestination ()
 
LogDestinationoperator= (const LogDestination &that)
 
int getThreshold () const
 
void setThreshold (int threshold)
 
bool write (const LogRecord &rec)
 

Protected Attributes

boost::filesystem::path _path
 
- Protected Attributes inherited from lsst::pex::logging::LogDestination
int _threshold
 
std::ostream * _strm
 
boost::shared_ptr< LogFormatter_frmtr
 

Detailed Description

a LogDestination represented by a file.

This class makes it easier to attach files to Logs via Python via Log.addDestination().

Definition at line 49 of file FileDestination.h.

Constructor & Destructor Documentation

lsst::pex::logging::FileDestination::FileDestination ( const std::string &  filepath,
const boost::shared_ptr< LogFormatter > &  formatter,
int  threshold = threshold::PASS_ALL,
bool  truncate = false 
)
inline

create a file destination. If the file does not exist, it will be created; otherwise, messages will be appended.

Parameters
filepaththe path to the log file to write messages to.
formatterthe LogFormatter to use to format the messages
thresholdthe minimum volume level required to pass a message to the stream. If not provided, it would be set to 0.
truncateif True, overwrite the previous contents; otherwise, new messages will be appended to the file.

Definition at line 64 of file FileDestination.h.

68  : LogDestination(new std::ofstream(filepath.c_str(),
69  truncate ? std::ios::out
70  : std::ios::app),
71  formatter, threshold),
72  _path(filepath)
73  { }
Extent< int, N > truncate(Extent< double, N > const &input)
LogDestination(std::ostream *strm, const boost::shared_ptr< LogFormatter > &formatter, int threshold=threshold::PASS_ALL)
create a destination with a threshold.
lsst::pex::logging::FileDestination::FileDestination ( const char *  filepath,
const boost::shared_ptr< LogFormatter > &  formatter,
int  threshold = threshold::PASS_ALL,
bool  truncate = false 
)
inline

create a file destination. If the file does not exist, it will be created; otherwise, messages will be appended.

Parameters
filepaththe path to the log file to write messages to.
formatterthe LogFormatter to use to format the messages
thresholdthe minimum volume level required to pass a message to the stream. If not provided, it would be set to 0.
truncateif True, overwrite the previous contents; otherwise, new messages will be appended to the file.

Definition at line 74 of file FileDestination.h.

78  : LogDestination(new std::ofstream(filepath,
79  truncate ? std::ios::out
80  : std::ios::app),
81  formatter, threshold),
82  _path(filepath)
83  { }
Extent< int, N > truncate(Extent< double, N > const &input)
LogDestination(std::ostream *strm, const boost::shared_ptr< LogFormatter > &formatter, int threshold=threshold::PASS_ALL)
create a destination with a threshold.
lsst::pex::logging::FileDestination::FileDestination ( const boost::filesystem::path &  filepath,
const boost::shared_ptr< LogFormatter > &  formatter,
int  threshold = threshold::PASS_ALL,
bool  truncate = false 
)
inline

create a file destination. If the file does not exist, it will be created; otherwise, messages will be appended.

Parameters
filepaththe path to the log file to write messages to.
formatterthe LogFormatter to use to format the messages
thresholdthe minimum volume level required to pass a message to the stream. If not provided, it would be set to 0.
truncateif True, overwrite the previous contents; otherwise, new messages will be appended to the file.

Definition at line 84 of file FileDestination.h.

88  : LogDestination(new std::ofstream(filepath.string().c_str(),
89  truncate ? std::ios::out
90  : std::ios::app),
91  formatter, threshold),
92  _path(filepath)
93  { }
Extent< int, N > truncate(Extent< double, N > const &input)
LogDestination(std::ostream *strm, const boost::shared_ptr< LogFormatter > &formatter, int threshold=threshold::PASS_ALL)
create a destination with a threshold.
lsst::pex::logging::FileDestination::FileDestination ( const boost::filesystem::path &  filepath,
bool  verbose = false,
int  threshold = threshold::PASS_ALL,
bool  truncate = false 
)

create a file destination. If the file does not exist, it will be created; otherwise, messages will be appended. The IndentedFormatter will be used to format the messages

Parameters
filepaththe path to the log file to write messages to.
verboseif True, make sure all properties are printed out to the destination
thresholdthe minimum volume level required to pass a message to the stream. If not provided, it would be set to 0.
truncateif True, overwrite the previous contents; otherwise, new messages will be appended to the file.

create a file destination. If the file does not exist, it will be created; otherwise, messages will be appended. The IndentedFormatter will be used to format the messages

Parameters
filepaththe path to the log file to write messages to.
thresholdthe minimum volume level required to pass a message to the stream. If not provided, it would be set to 0.
truncateif True, overwrite the previous contents; otherwise, new messages will be appended to the file.

Definition at line 44 of file FileDestination.cc.

46  : LogDestination(new std::ofstream(filepath.string().c_str(),
47  truncate ? std::ios::out : std::ios::app),
48  boost::shared_ptr<LogFormatter>(new IndentedFormatter(verbose)),
49  threshold),
50  _path(filepath)
51 { }
Extent< int, N > truncate(Extent< double, N > const &input)
LogDestination(std::ostream *strm, const boost::shared_ptr< LogFormatter > &formatter, int threshold=threshold::PASS_ALL)
create a destination with a threshold.
lsst::pex::logging::FileDestination::FileDestination ( const std::string &  filepath,
bool  verbose = false,
int  threshold = threshold::PASS_ALL,
bool  truncate = false 
)

create a file destination. If the file does not exist, it will be created; otherwise, messages will be appended. The IndentedFormatter will be used to format the messages

Parameters
filepaththe path to the log file to write messages to.
verboseif True, make sure all properties are printed out to the destination
thresholdthe minimum volume level required to pass a message to the stream. If not provided, it would be set to 0.
truncateif True, overwrite the previous contents; otherwise, new messages will be appended to the file.

create a file destination. If the file does not exist, it will be created; otherwise, messages will be appended. The IndentedFormatter will be used to format the messages

Parameters
filepaththe path to the log file to write messages to.
thresholdthe minimum volume level required to pass a message to the stream. If not provided, it would be set to 0.
truncateif True, overwrite the previous contents; otherwise, new messages will be appended to the file.

Definition at line 52 of file FileDestination.cc.

54  : LogDestination(new std::ofstream(filepath.c_str(),
55  truncate ? std::ios::out : std::ios::app),
56  boost::shared_ptr<LogFormatter>(new IndentedFormatter(verbose)),
57  threshold),
58  _path(filepath)
59 { }
Extent< int, N > truncate(Extent< double, N > const &input)
LogDestination(std::ostream *strm, const boost::shared_ptr< LogFormatter > &formatter, int threshold=threshold::PASS_ALL)
create a destination with a threshold.
lsst::pex::logging::FileDestination::FileDestination ( const char *  filepath,
bool  verbose = false,
int  threshold = threshold::PASS_ALL,
bool  truncate = false 
)

create a file destination. If the file does not exist, it will be created; otherwise, messages will be appended. The IndentedFormatter will be used to format the messages

Parameters
filepaththe path to the log file to write messages to.
verboseif True, make sure all properties are printed out to the destination
thresholdthe minimum volume level required to pass a message to the stream. If not provided, it would be set to 0.
truncateif True, overwrite the previous contents; otherwise, new messages will be appended to the file.

create a file destination. If the file does not exist, it will be created; otherwise, messages will be appended. The IndentedFormatter will be used to format the messages

Parameters
filepaththe path to the log file to write messages to.
thresholdthe minimum volume level required to pass a message to the stream. If not provided, it would be set to 0.
truncateif True, overwrite the previous contents; otherwise, new messages will be appended to the file.

Definition at line 60 of file FileDestination.cc.

62  : LogDestination(new std::ofstream(filepath,
63  truncate ? std::ios::out : std::ios::app),
64  boost::shared_ptr<LogFormatter>(new IndentedFormatter(verbose)),
65  threshold),
66  _path(filepath)
67 { }
Extent< int, N > truncate(Extent< double, N > const &input)
LogDestination(std::ostream *strm, const boost::shared_ptr< LogFormatter > &formatter, int threshold=threshold::PASS_ALL)
create a destination with a threshold.
lsst::pex::logging::FileDestination::~FileDestination ( )
virtual

Definition at line 72 of file FileDestination.cc.

72  {
73  std::ofstream *ofstrm = dynamic_cast<std::ofstream*>(_strm);
74  if (ofstrm != NULL && ofstrm->is_open()) {
75  try {
76  ofstrm->flush();
77  ofstrm->close();
78  }
79  catch (...) { }
80  }
81  delete _strm;
82 }

Member Function Documentation

const boost::filesystem::path& lsst::pex::logging::FileDestination::getPath ( ) const
inline

Definition at line 120 of file FileDestination.h.

120 { return _path; }

Member Data Documentation

boost::filesystem::path lsst::pex::logging::FileDestination::_path
protected

Definition at line 123 of file FileDestination.h.


The documentation for this class was generated from the following files: