XRootD
Loading...
Searching...
No Matches
XrdCl::LogOutFile Class Reference

Write log messages to a file. More...

#include <XrdClLog.hh>

Inheritance diagram for XrdCl::LogOutFile:
Collaboration diagram for XrdCl::LogOutFile:

Public Member Functions

 LogOutFile ()
virtual ~LogOutFile ()
void Close ()
 Close the log file.
bool Open (const std::string &fileName)
 Open the log file.
virtual void Write (const std::string &message)
Public Member Functions inherited from XrdCl::LogOut
virtual ~LogOut ()

Detailed Description

Write log messages to a file.

Definition at line 64 of file XrdClLog.hh.

Constructor & Destructor Documentation

◆ LogOutFile()

XrdCl::LogOutFile::LogOutFile ( )
inline

Definition at line 67 of file XrdClLog.hh.

67: pFileDes(-1) {};

◆ ~LogOutFile()

virtual XrdCl::LogOutFile::~LogOutFile ( )
inlinevirtual

Definition at line 68 of file XrdClLog.hh.

68{ Close(); };
void Close()
Close the log file.
Definition XrdClLog.cc:55

References Close().

Here is the call graph for this function:

Member Function Documentation

◆ Close()

void XrdCl::LogOutFile::Close ( )

Close the log file.

Definition at line 55 of file XrdClLog.cc.

56 {
57 if( pFileDes != -1 )
58 {
59 close( pFileDes );
60 pFileDes = -1;
61 }
62 }
#define close(a)
Definition XrdPosix.hh:43

References close.

Referenced by ~LogOutFile().

Here is the caller graph for this function:

◆ Open()

bool XrdCl::LogOutFile::Open ( const std::string & fileName)

Open the log file.

Definition at line 39 of file XrdClLog.cc.

40 {
41 int fd = open( filename.c_str(), O_WRONLY | O_APPEND | O_CREAT, S_IRUSR | S_IWUSR );
42 if( fd < 0 )
43 {
44 std::cerr << "Unable to open " << filename << " " << XrdSysE2T( errno );
45 std::cerr << std::endl;
46 return false;
47 }
48 pFileDes = fd;
49 return true;
50 }
#define open
Definition XrdPosix.hh:71
const char * XrdSysE2T(int errcode)
Definition XrdSysE2T.cc:104

References open, and XrdSysE2T().

Referenced by XrdCl::DefaultEnv::SetLogFile().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Write()

void XrdCl::LogOutFile::Write ( const std::string & message)
virtual

Write a message to the destination

Parameters
messagemessage to be written

Implements XrdCl::LogOut.

Definition at line 67 of file XrdClLog.cc.

68 {
69 if( unlikely( pFileDes == -1 ) )
70 {
71 std::cerr << "Log file not opened" << std::endl;
72 return;
73 }
74 int ret = write( pFileDes, message.c_str(), message.length() );
75 if( ret < 0 )
76 {
77 std::cerr << "Unable to write to the log file: " << XrdSysE2T( errno );
78 std::cerr << std::endl;
79 return;
80 }
81 }
#define unlikely(x)
#define write(a, b, c)
Definition XrdPosix.hh:110

References unlikely, write, and XrdSysE2T().

Here is the call graph for this function:

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