本文整理汇总了C++中LogErr函数的典型用法代码示例。如果您正苦于以下问题:C++ LogErr函数的具体用法?C++ LogErr怎么用?C++ LogErr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了LogErr函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: curl_easy_setopt
bool CurlWrapper::download_text(const std::string &url, std::string &content)
{
auto curl = std::shared_ptr<CURL>(curl_easy_init(), curl_easy_cleanup);
std::string readBuffer;
if (nullptr != curl) {
CURLcode res;
curl_easy_setopt(curl.get(), CURLOPT_CONNECTTIMEOUT, 5L);
curl_easy_setopt(curl.get(), CURLOPT_URL, url.c_str());
curl_easy_setopt(curl.get(), CURLOPT_WRITEFUNCTION, write_callback);
curl_easy_setopt(curl.get(), CURLOPT_WRITEDATA, &readBuffer);
res = curl_easy_perform(curl.get());
content = readBuffer;
if (res == CURLcode::CURLE_OK) {
return true;
} else {
LogErr() << "Error while downloading text, curl error code: "
<< curl_easy_strerror(res);
return false;
}
} else {
LogErr() << "Error: cannot start uploading because of curl initialization error. ";
return false;
}
}
示例2: gather_statistic
static rc_t gather_statistic( statistic * data,
KDirectory *dir,
context *ctx )
{
VDBManager *my_manager;
/* because this tool is linked against the write-version
of vdb and kdb, there is no Read-Manager available... */
rc_t rc = VDBManagerMakeUpdate ( &my_manager, dir );
if ( rc != 0 )
LogErr( klogInt, rc, "VDBManagerMakeUpdate() failed\n" );
else
{
const VDatabase *my_database;
rc = VDBManagerOpenDBRead( my_manager, &my_database, NULL, "%s", ctx->src_path );
if ( rc != 0 )
LogErr( klogInt, rc, "VDBManagerOpenDBRead() failed\n" );
else
{
/* ******************************************************* */
rc = read_statistic_from_table( data, dir, ctx, my_database,
"PRIMARY_ALIGNMENT" );
/* ******************************************************* */
VDatabaseRelease( my_database );
}
VDBManagerRelease( my_manager );
}
return rc;
}
示例3: LogDebug
Json::Value Playlist::LoadJSON(const char *filename)
{
LogDebug(VB_PLAYLIST, "Playlist::LoadJSON(%s)\n", filename);
Json::Value root;
Json::Reader reader;
if (!FileExists(m_filename.c_str()))
{
LogErr(VB_PLAYLIST, "Playlist %s does not exist\n", m_filename.c_str());
return root;
}
struct stat attr;
stat(m_filename.c_str(), &attr);
LogDebug(VB_PLAYLIST, "Playlist Last Modified: %s\n", ctime(&attr.st_mtime));
m_fileTime = attr.st_mtime;
std::ifstream t(m_filename);
std::stringstream buffer;
buffer << t.rdbuf();
bool success = reader.parse(buffer.str(), root);
if (!success)
{
LogErr(VB_PLAYLIST, "Error parsing %s\n", m_filename.c_str());
return root;
}
return root;
}
示例4: curl_slist_append
bool CurlWrapper::upload_file(const std::string &url,
const std::string &path,
const progress_callback_t &progress_callback)
{
auto curl = std::shared_ptr<CURL>(curl_easy_init(), curl_easy_cleanup);
CURLcode res;
if (nullptr != curl) {
struct dl_up_progress prog;
prog.progress_callback = progress_callback;
curl_httppost *post = NULL;
curl_httppost *last = NULL;
struct curl_slist *chunk = NULL;
// avoid sending 'Expect: 100-Continue' header, required by some server implementations
chunk = curl_slist_append(chunk, "Expect:");
// disable chunked upload
chunk = curl_slist_append(chunk, "Content-Encoding: ");
// to allow efficient file upload, we need to add the file size to the header
std::string filesize_header = "File-Size: " + to_string(get_file_size(path));
chunk = curl_slist_append(chunk, filesize_header.c_str());
curl_formadd(
&post, &last, CURLFORM_COPYNAME, "file", CURLFORM_FILE, path.c_str(), CURLFORM_END);
curl_easy_setopt(curl.get(), CURLOPT_CONNECTTIMEOUT, 5L);
curl_easy_setopt(curl.get(), CURLOPT_PROGRESSFUNCTION, upload_progress_update);
curl_easy_setopt(curl.get(), CURLOPT_PROGRESSDATA, &prog);
curl_easy_setopt(curl.get(), CURLOPT_VERBOSE, 1L);
curl_easy_setopt(curl.get(), CURLOPT_HTTPHEADER, chunk);
curl_easy_setopt(curl.get(), CURLOPT_URL, url.c_str());
curl_easy_setopt(curl.get(), CURLOPT_HTTPPOST, post);
curl_easy_setopt(curl.get(), CURLOPT_NOPROGRESS, 0L);
res = curl_easy_perform(curl.get());
curl_slist_free_all(chunk);
curl_formfree(post);
if (res == CURLcode::CURLE_OK) {
if (nullptr != progress_callback) {
progress_callback(100, Status::Finished, CURLcode::CURLE_OK);
}
return true;
} else {
if (nullptr != progress_callback) {
progress_callback(0, Status::Error, res);
}
LogErr() << "Error while uploading file, curl error code: " << curl_easy_strerror(res);
return false;
}
} else {
LogErr() << "Error: cannot start uploading because of curl initialization error.";
return false;
}
}
示例5: LogErr
bool TileManager::LoadTileInfo( const TiXmlElement *strip ) {
std::string tileName, tileType;
int tileId = 0;
const char *name = strip->Attribute( "name" );
if ( name ) {
tileName = name;
} else {
LogErr( "No name specified for tile." );
return false;
}
const char *type = strip->Attribute( "type" );
if ( type ) {
tileType = type;
} else {
LogErr( "No type specified for tile." );
return false;
}
strip->QueryIntAttribute( "id", &tileId );
Tile tile( tileType, tileName, tileId );
m_tileDataName.insert(
std::pair<std::string, Tile>( tileName, tile ));
m_tileDataId.insert(
std::pair<int, Tile*>( tileId, &m_tileDataName[tileName] ));
return true;
}
示例6: MemInit
void *MemAlloc (unsigned int size, char * var, char * pszFile, int nLine, int bZeroFill)
{
int *ptr;
if (!bMemInitialized)
MemInit ();
if (!size)
return NULL;
if (nMemBlockId == nDbgMemBlockId)
nDbgMemBlockId = nDbgMemBlockId;
#if LONG_MEM_ID
ptr = malloc (size + CHECKSIZE + sizeof (int) + 256);
#else
ptr = malloc (size + CHECKSIZE + sizeof (int));
#endif
if (!ptr) {
LogErr ("\nMEM_OUT_OF_MEMORY: Malloc returned NULL\n");
LogErr ("\tVar %s, file %s, nLine %d.\n", var, pszFile, nLine);
Int3 ();
return NULL;
}
#if LONG_MEM_ID
sprintf ((char *) ptr, "%s:%d", pszFile, nLine);
ptr = (int *) (((char *) ptr) + 256);
#endif
*ptr++ = size;
nBytesMalloced += size;
memset ((char *) ptr + size, CHECKBYTE, CHECKSIZE);
if (bZeroFill)
memset (ptr, 0, size);
RegisterMemBlock (ptr, pszFile, nLine);
return (void *) ptr;
}
示例7: assert
void NetCore::_connect(SockData* sockData)
{
assert(sockData != NULL);
SockData* newSock = new SockData;
socklen_t addrLen = sizeof(sockaddr_in);
newSock->sock = accept(sockData->sock, (sockaddr*)&(newSock->addr), &addrLen);
if (newSock->sock < 0)
{
LogErr("accept Failed: %s\n", strerror(errno));
delete newSock;
return;
}
newSock->key = rand();
struct epoll_event ev;
ev.events = EPOLLIN;
ev.data.ptr = newSock;
if (epoll_ctl(_eplFd, EPOLL_CTL_ADD, newSock->sock, &ev) < 0)
{
LogErr("epoll_ctl failed: %s\n", strerror(errno));
::close(newSock->sock);
delete newSock;
return;
}
_cliMap.insert(make_pair(newSock->sock, newSock));
LogMsg("%s:%u connect in\n", inet_ntoa(newSock->addr.sin_addr), ntohs(newSock->addr.sin_port));
}
示例8: Server
static
rc_t
Server( KNSManager* mgr )
{
rc_t rc = 0;
KEndPoint ep;
String name;
CONST_STRING(&name, KEYRING_IPC_NAME);
rc = KNSManagerInitIPCEndpoint(mgr, &ep, &name);
if (rc == 0)
{
KSocket* listener;
rc = KNSMakeListener ( &listener, &ep );
if (rc == 0)
{
shutDown = false;
while (!shutDown && rc == 0)
{
KStream* stream;
LogMsg ( klogInfo, "KeyringServer: listening");
rc = KNSListen ( listener, &stream ); /* may not return from here if no more incoming connections arrive */
if (rc == 0)
{
KThread* worker;
LogMsg ( klogInfo, "KeyringServer: detected connection");
rc = KThreadMake ( &worker, WorkerThreadFn, stream);
if (rc == 0 && worker != NULL)
{
KThreadWait(worker, NULL);
LogMsg ( klogInfo, "KeyringServer: out of worker");
}
else
LogErr(klogErr, rc, "KeyringServer: KThreadMake failed");
}
else
LogErr(klogErr, rc, "KeyringServer: KNSListen failed");
}
LogMsg ( klogInfo, "KeyringServer: shutting down");
/* TODO: make sure no incoming messages get dropped (stop accepting connections? wait for all active threads to exit?)
- lock the server */
if (keyring != NULL)
{
KeyRingRelease(keyring);
keyring = NULL;
}
KSocketRelease(listener);
}
else
LogErr(klogErr, rc, "KeyringServer: KNSMakeListener failed");
}
else
LogErr(klogErr, rc, "KeyringServer: KNSManagerInitIPCEndpoint failed");
LogMsg ( klogInfo, "KeyringServer: listener shut down");
return rc;
}
示例9: KMain
rc_t CC KMain (int argc, char * argv[])
{
rc_t rc = 0;
KDirectory* wd;
KLogLevelSet(klogInfo);
LogMsg ( klogInfo, "KeyringServer: starting");
rc = KDirectoryNativeDir (&wd);
if (rc == 0)
{
KFile* lockedFile;
const char* dataDir;
char lockFileName[MAX_PATH];
if (argc < 2 || argv[1] == NULL)
dataDir = KeyRingDefaultDataDir;
else
dataDir = argv[1];
rc = string_printf(lockFileName, sizeof(lockFileName)-1, NULL, "%s/keyring_lock", dataDir);
if (rc == 0)
{
rc = KDirectoryCreateExclusiveAccessFile(wd, &lockedFile, true, 0600, kcmOpen, "%s", lockFileName);
if (rc == 0)
{
KNSManager* mgr;
rc = KNSManagerMake(&mgr);
if (rc == 0)
{
rc = string_printf(keyRingFileName, sizeof(keyRingFileName)-1, NULL, "%s/keyring", dataDir);
if (rc == 0)
rc = Server(mgr);
KNSManagerRelease(mgr);
}
else
LogErr(klogErr, rc, "KeyringServer: KNSManagerMake failed");
KFileRelease(lockedFile);
LogMsg ( klogInfo, "KeyringServer: removing lock file.");
KDirectoryRemove(wd, true, "%s", lockFileName);
}
else
{ /*TODO: check for stale lock file*/
LogMsg ( klogInfo, "KeyringServer: another instance appears to be running.");
rc = 0;
}
}
else
LogErr ( klogErr, rc, "KeyringServer: failed to build the lock file name" );
KDirectoryRelease(wd);
}
else
LogErr(klogErr, rc, "KeyringServer: KDirectoryNativeDir failed");
LogMsg ( klogInfo, "KeyringServer: finishing");
return rc;
}
示例10: omxplayer_StartPlaying
int omxplayer_StartPlaying(const char *filename)
{
char fullVideoPath[2048];
LogDebug(VB_MEDIAOUT, "omxplayer_StartPlaying(%s)\n", filename);
bzero(&mediaOutputStatus, sizeof(mediaOutputStatus));
if (snprintf(fullVideoPath, 2048, "%s/%s", getVideoDirectory(), filename)
>= 2048)
{
LogErr(VB_MEDIAOUT, "Unable to play %s, full path name too long\n",
filename);
return 0;
}
if (getFPPmode() == REMOTE_MODE)
CheckForHostSpecificFile(getSetting("HostName"), fullVideoPath);
if (!FileExists(fullVideoPath))
{
LogErr(VB_MEDIAOUT, "%s does not exist!\n", fullVideoPath);
return 0;
}
// Create Pipes to/from omxplayer
pid_t omxplayerPID = forkpty(&pipeFromOMX[0], 0, 0, 0);
if (omxplayerPID == 0) // omxplayer process
{
ShutdownControlSocket();
seteuid(1000); // 'pi' user
execl("/opt/fpp/scripts/omxplayer", "/opt/fpp/scripts/omxplayer", fullVideoPath, NULL);
LogErr(VB_MEDIAOUT, "omxplayer_StartPlaying(), ERROR, we shouldn't "
"be here, this means that execl() failed\n");
exit(EXIT_FAILURE);
}
else // Parent process
{
mediaOutput->childPID = omxplayerPID;
}
// Clear active file descriptor sets
FD_ZERO (&omx_active_fd_set);
// Set description for reading from omxplayer
FD_SET (pipeFromOMX[0], &omx_active_fd_set);
mediaOutputStatus.status = MEDIAOUTPUTSTATUS_PLAYING;
omxVolumeShift = omxplayer_GetVolumeShift(getVolume());
return 1;
}
示例11: dumpraddr
static void dumpraddr (unsigned char *a)
{
unsigned short port;
LogErr (" [%u.%u.%u.%u",a [0],a [1],a [2],a [3]);
port= (unsigned short)ntohs (* (unsigned short *) (a+4));
if (port)
LogErr (":%u",port);
LogErr ("]");
}
示例12: Ast
bool CConnClient::Send(const void* pData,uint32 uCurSize)
{
Ast( uCurSize> 0 );
if( !IsConnected() )
return false;
if(uCurSize<=0xff)
{
CGac2GasGC_Small_Shell_Message cmd;
m_pSlowSigner->SlowSignOnData(pData,uCurSize,&cmd);
cmd.uobClientTime = CTimeSystemClient::Inst()->GetFrameTime();
cmd.uobClientKnownServerFrameTime = m_uLastSyncedServerFrameTime;
cmd.usbDataLength = static_cast<uint8>(uCurSize);
TConnection<CTraitsClient>::SendCoreCmd(&cmd);
if(m_uLastSyncedServerFrameTime > 100000000000000000)
{
ostringstream strm;
strm << "CGac2GasGC_Small_Shell_Message" << m_uLastSyncedServerFrameTime;
LogErr("ClientKnownServerFrameTime Err", strm.str());
}
}
else if(uCurSize<=0xffff)
{
CGac2GasGC_Middle_Shell_Message cmd;
m_pSlowSigner->SlowSignOnData(pData,uCurSize,&cmd);
cmd.uobClientTime = CTimeSystemClient::Inst()->GetFrameTime();
cmd.uobClientKnownServerFrameTime = m_uLastSyncedServerFrameTime;
cmd.udbDataLength = static_cast<uint16>(uCurSize);
TConnection<CTraitsClient>::SendCoreCmd(&cmd);
if(m_uLastSyncedServerFrameTime > 100000000000000000)
{
ostringstream strm;
strm << "CGac2GasGC_Middle_Shell_Message" << m_uLastSyncedServerFrameTime;
LogErr("ClientKnownServerFrameTime Err", strm.str());
}
}
else
{
LogErr("客户端逻辑消息大小最大不能超过64k");
CoreShutDown("客户端逻辑消息大小最大不能超过64k");
}
SendCoreMsg(pData,uCurSize);
return true;
}
示例13: read_statistic_from_table
static rc_t read_statistic_from_table( statistic * data,
KDirectory *dir,
context *ctx,
const VDatabase *my_database,
const char *table_name )
{
const VTable *my_table;
rc_t rc = VDatabaseOpenTableRead( my_database, &my_table, "%s", table_name );
if ( rc != 0 )
{
LogErr( klogInt, rc, "VDatabaseOpenTableRead() failed\n" );
}
else
{
const VCursor *my_cursor;
rc = VTableCreateCursorRead( my_table, &my_cursor );
if ( rc != 0 )
LogErr( klogInt, rc, "VTableCreateCursorRead() failed\n" );
else
{
/*
spot_pos sequence;
rc = make_spot_pos( &sequence, my_database );
if ( rc == 0 )
{
*/
statistic_reader reader;
/*
rc = make_statistic_reader( &reader, &sequence, dir, my_cursor,
ctx->exclude_file_path, ctx->info );
*/
rc = make_statistic_reader( &reader, NULL, dir, my_cursor,
ctx->exclude_file_path, ctx->info );
if ( rc == 0 )
{
/* ******************************************************* */
rc = read_loop( data, ctx, &reader, my_cursor );
/* ******************************************************* */
whack_reader( &reader );
}
/*
whack_spot_pos( &sequence );
}
*/
VCursorRelease( my_cursor );
}
VTableRelease( my_table );
}
return rc;
}
示例14: LoadTerrain
void LoadTerrain (char *filename)
{
grsBitmap bmHeight;
int iff_error;
int i, j;
ubyte h, hMin, hMax;
LogErr (" loading terrain height map\n");
iff_error = iff_read_bitmap (filename, &bmHeight, BM_LINEAR);
if (iff_error != IFF_NO_ERROR) {
#if TRACE
con_printf (1, "File %s - IFF error: %s", filename, iff_errormsg (iff_error));
#endif
Error ("File %s - IFF error: %s", filename, iff_errormsg (iff_error));
}
if (gameData.render.terrain.pHeightMap)
D2_FREE (gameData.render.terrain.pHeightMap)
else
atexit (FreeTerrainHeightMap); //first time
gameData.render.terrain.nGridW = bmHeight.bmProps.w;
gameData.render.terrain.nGridH = bmHeight.bmProps.h;
Assert (gameData.render.terrain.nGridW <= TERRAIN_GRID_MAX_SIZE);
Assert (gameData.render.terrain.nGridH <= TERRAIN_GRID_MAX_SIZE);
LogErr ("heightmap loaded, size=%dx%d\n", gameData.render.terrain.nGridW, gameData.render.terrain.nGridH);
gameData.render.terrain.pHeightMap = bmHeight.bmTexBuf;
hMax = 0;
hMin = 255;
for (i = 0; i < gameData.render.terrain.nGridW; i++)
for (j = 0; j < gameData.render.terrain.nGridH; j++) {
h = HEIGHT (i, j);
if (h > hMax)
hMax = h;
if (h < hMin)
hMin = h;
}
for (i = 0; i < gameData.render.terrain.nGridW; i++) {
for (j = 0; j < gameData.render.terrain.nGridH; j++) {
HEIGHT (i, j) -= hMin;
}
}
// D2_FREE (bmHeight.bmTexBuf);
gameData.render.terrain.bmP = gameData.endLevel.terrain.bmP;
#if 0 //the following code turns the (palettized) terrain texture into a white TGA texture for testing
gameData.render.terrain.bmP->bmProps.rowSize *= 4;
gameData.render.terrain.bmP->bmProps.flags |= BM_FLAG_TGA;
D2_FREE (gameData.render.terrain.bmP->bmTexBuf);
gameData.render.terrain.bmP->bmTexBuf = D2_ALLOC (gameData.render.terrain.bmP->bmProps.h * gameData.render.terrain.bmP->bmProps.rowSize);
memset (gameData.render.terrain.bmP->bmTexBuf, 0xFF, gameData.render.terrain.bmP->bmProps.h * gameData.render.terrain.bmP->bmProps.rowSize);
#endif
LogErr (" building terrain light map\n");
BuildTerrainLightMap ();
}
示例15: LogErr
int NetCore::_listen(u16 port)
{
struct sockaddr_in my_addr;
if ((_servSock = socket(AF_INET, SOCK_STREAM, 0)) < 0)
{
LogErr("create socket failed: %s\n", strerror(errno));
return -1;
}
my_addr.sin_family = AF_INET;
my_addr.sin_port = htons(port);
my_addr.sin_addr.s_addr = INADDR_ANY;
int flag = 1, len = sizeof(int);
if(setsockopt(_servSock, SOL_SOCKET, SO_REUSEADDR, &flag, len) < 0)
{
LogErr("setsockopt Failed: %s\n", strerror(errno));
::close(_servSock);
return -1;
}
if (bind(_servSock, (struct sockaddr *)&my_addr, sizeof(struct sockaddr)) == -1)
{
LogErr("bind 0.0.0.0:%u failed: %s\n", port, strerror(errno));
::close(_servSock);
return -1;
}
if (listen(_servSock, EPL_MAX_EVENTS) == -1)
{
LogErr("listen on 0.0.0.0:%u failed: %s\n", port, strerror(errno));
::close(_servSock);
return -1;
}
SockData* skData = new SockData();
skData->sock = _servSock;
skData->key = 0;
struct epoll_event ev;
ev.events = EPOLLIN;
ev.data.ptr = skData;
if (epoll_ctl(_eplFd, EPOLL_CTL_ADD, _servSock, &ev) < 0)
{
LogErr("epoll_ctl failed: %s\n", strerror(errno));
::close(_servSock);
delete skData;
return -1;
}
return 0;
}