greenplumn syslibwrapper 源码

  • 2022-08-18
  • 浏览 (266)

greenplumn syslibwrapper 代码

文件路径:/src/backend/gporca/libgpos/src/common/syslibwrapper.cpp

//---------------------------------------------------------------------------
//	Greenplum Database
//	Copyright (C) 2011 EMC Corp.
//
//	@filename:
//		syslibwrapper.cpp
//
//	@doc:
//		Wrapper for functions in system library
//
//---------------------------------------------------------------------------

#include "gpos/common/syslibwrapper.h"

#include <sys/stat.h>
#include <sys/time.h>
#include <syslog.h>

#include "gpos/assert.h"
#include "gpos/error/CException.h"
#include "gpos/utils.h"


using namespace gpos;


//---------------------------------------------------------------------------
//	@function:
//		syslib::GetTimeOfDay
//
//	@doc:
//		Get the date and time
//
//---------------------------------------------------------------------------
void
gpos::syslib::GetTimeOfDay(TIMEVAL *tv, TIMEZONE *tz)
{
	GPOS_ASSERT(nullptr != tv);

	INT res GPOS_ASSERTS_ONLY = gettimeofday(tv, tz);

	GPOS_ASSERT(0 == res);
}


//---------------------------------------------------------------------------
//	@function:
//		syslib::GetRusage
//
//	@doc:
//		Get system and user time
//
//---------------------------------------------------------------------------
void
gpos::syslib::GetRusage(RUSAGE *usage)
{
	GPOS_ASSERT(nullptr != usage);

	INT res GPOS_ASSERTS_ONLY = getrusage(RUSAGE_SELF, usage);

	GPOS_ASSERT(0 == res);
}


//---------------------------------------------------------------------------
//	@function:
//		syslib::OpenLog
//
//	@doc:
//		Open a connection to the system logger for a program
//
//---------------------------------------------------------------------------
void
gpos::syslib::OpenLog(const CHAR *ident, INT option, INT facility)
{
	openlog(ident, option, facility);
}


//---------------------------------------------------------------------------
//	@function:
//		syslib::SysLog
//
//	@doc:
//		Generate a log message
//
//---------------------------------------------------------------------------
void
gpos::syslib::SysLog(INT priority, const CHAR *format)
{
	syslog(priority, "%s", format);
}


//---------------------------------------------------------------------------
//	@function:
//		syslib::CloseLog
//
//	@doc:
//		Close the descriptor being used to write to the system logger
//
//---------------------------------------------------------------------------
void
gpos::syslib::CloseLog()
{
	closelog();
}

// EOF

相关信息

greenplumn 源码目录

相关文章

greenplumn CAutoTimer 源码

greenplumn CBitSet 源码

greenplumn CBitSetIter 源码

greenplumn CBitVector 源码

greenplumn CDebugCounter 源码

greenplumn CHeapObject 源码

greenplumn CMainArgs 源码

greenplumn CRandom 源码

greenplumn CRefCount 源码

greenplumn CStackDescriptor 源码

0  赞