本文整理汇总了C++中PLOG函数的典型用法代码示例。如果您正苦于以下问题:C++ PLOG函数的具体用法?C++ PLOG怎么用?C++ PLOG使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PLOG函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PLOG
void Pipe2Sock::OnShutdown()
{
if (listen_pipe.IsOpen()) listen_pipe.Close();
if (socket.IsOpen())
{
if(dst_addr.IsMulticast())
{
socket.LeaveGroup(dst_addr);
}
socket.Close();
}
PLOG(PL_ERROR, "pipe2Sock: Done.\n");
} // end Pipe2Sock::OnShutdown()
示例2: deletePath
void deletePath(const char* path) {
struct stat statbuf;
if (stat(path, &statbuf) == 0) {
if (S_ISDIR(statbuf.st_mode)) {
deleteRecursive(path);
rmdir(path);
} else {
unlink(path);
}
} else {
PLOG(ERROR) << "deletePath stat failed for " << path;;
}
}
示例3: OpenDebugPipe
/**
* @brief log debug messages to a datagram ProtoPipe (PLOG only)
*/
bool OpenDebugPipe(const char* pipeName)
{
#ifndef SIMULATE
if (!debug_pipe.Connect(pipeName))
{
PLOG(PL_ERROR, "OpenDebugPipe: error opening/connecting debug_pipe!\n");
return false;
}
return true;
#else
return false;
#endif // if/else !SIMULATE
} // end OpenDebugPipe()
示例4: GetBootEventPath
// The implementation of AddBootEventValue makes use of the mtime file
// attribute to store the value associated with a boot event in order to
// optimize on-disk size requirements and small-file thrashing.
void BootEventRecordStore::AddBootEventWithValue(
const std::string& event, int32_t value) {
std::string record_path = GetBootEventPath(event);
int record_fd = creat(record_path.c_str(), S_IRUSR | S_IWUSR);
if (record_fd == -1) {
PLOG(ERROR) << "Failed to create " << record_path;
return;
}
// Writing the value as content in the record file is a debug measure to
// ensure the validity of the file mtime value, i.e., to check that the record
// file mtime values are not changed once set.
// TODO(jhawkins): Remove this block.
if (!android::base::WriteStringToFd(std::to_string(value), record_fd)) {
PLOG(ERROR) << "Failed to write value to " << record_path;
close(record_fd);
return;
}
// Fill out the stat structure for |record_path| in order to get the atime to
// set in the utime() call.
struct stat file_stat;
if (stat(record_path.c_str(), &file_stat) == -1) {
PLOG(ERROR) << "Failed to read " << record_path;
close(record_fd);
return;
}
// Set the |modtime| of the file to store the value of the boot event while
// preserving the |actime| (as read by stat).
struct utimbuf times = {/* actime */ file_stat.st_atime, /* modtime */ value};
if (utime(record_path.c_str(), ×) == -1) {
PLOG(ERROR) << "Failed to set mtime for " << record_path;
close(record_fd);
return;
}
close(record_fd);
}
示例5: remote_read
// On Android devices, we rely on the kernel to provide buffered read.
// So we can recover automatically from EOVERFLOW.
static int remote_read(apacket* p, usb_handle* usb) {
if (usb_read(usb, &p->msg, sizeof(amessage)) != sizeof(amessage)) {
PLOG(ERROR) << "remote usb: read terminated (message)";
return -1;
}
if (p->msg.data_length) {
if (p->msg.data_length > MAX_PAYLOAD) {
PLOG(ERROR) << "remote usb: read overflow (data length = " << p->msg.data_length << ")";
return -1;
}
p->payload.resize(p->msg.data_length);
if (usb_read(usb, &p->payload[0], p->payload.size())
!= static_cast<int>(p->payload.size())) {
PLOG(ERROR) << "remote usb: terminated (data)";
return -1;
}
}
return 0;
}
示例6: PLOG
bool Fifo::write(const struct iovec* iov, size_t iovcnt) noexcept {
if (folly::writevNoInt(fd_, iov, iovcnt) == -1) {
if (errno != EAGAIN) {
PLOG(WARNING) << "Error writing to debug pipe.";
}
if (errno == EPIPE) {
disconnect();
}
return false;
}
return true;
}
示例7: Close
bool ProtoXml::IterParser::Open(const char* fileName, const char* filterPath)
{
Close(); // just in case already open
if (NULL == (reader_ptr = xmlNewTextReaderFilename(fileName)))
{
PLOG(PL_ERROR, "ProtoXml::IterParser::Open() xmlNewTextReaderFilename() error: %s\n",
GetErrorString());
return false;
}
if (NULL != filterPath)
IterFilterBase::SetFilter(filterPath);
return true;
} // end ProtoXml::IterParser::Open()
示例8: write_persistent_property
static void write_persistent_property(const char *name, const char *value)
{
char tempPath[PATH_MAX];
char path[PATH_MAX];
int fd;
snprintf(tempPath, sizeof(tempPath), "%s/.temp.XXXXXX", PERSISTENT_PROPERTY_DIR);
fd = mkstemp(tempPath);
if (fd < 0) {
PLOG(ERROR) << "Unable to write persistent property to temp file " << tempPath;
return;
}
write(fd, value, strlen(value));
fsync(fd);
close(fd);
snprintf(path, sizeof(path), "%s/%s", PERSISTENT_PROPERTY_DIR, name);
if (rename(tempPath, path)) {
PLOG(ERROR) << "Unable to rename persistent property file " << tempPath << " to " << path;
unlink(tempPath);
}
}
示例9: randomKey
virtual CipherKey randomKey(int length) {
CipherKey key(length);
if (length == 0) return key;
#ifdef HAVE_SEC_RANDOM_H
if (SecRandomCopyBytes(kSecRandomDefault, key.size(), key.data()) < 0) {
PLOG(ERROR) << "random key generation failure for length " << length;
key.reset();
}
#else
#error No random number generator provided.
#endif
return key;
}
示例10: commit_transaction
static int commit_transaction(db_con_t * _h)
{
PGresult *mr;
mr = PQexec(CON_CONNECTION(_h), "COMMIT");
if(!mr || PQresultStatus(mr) != PGRES_COMMAND_OK)
{
PLOG("commit_transaction", "error");
return -1;
}
PQclear(mr);
return(0);
}
示例11: db_close
void db_close(db_con_t* _h)
{
DLOG("db_close", "entry");
if(! _h)
{
PLOG("db_close", "no handle passed, ignored");
return;
}
disconnect_db(_h);
aug_free(_h);
}
示例12: su
inline bool su(const std::string& user)
{
struct passwd* passwd;
if ((passwd = ::getpwnam(user.c_str())) == NULL) {
PLOG(ERROR) << "Failed to get user information for '"
<< user
<< "', getpwnam";
return false;
}
if (::setgid(passwd->pw_gid) < 0) {
PLOG(ERROR) << "Failed to set group id, setgid";
return false;
}
if (::setuid(passwd->pw_uid) < 0) {
PLOG(ERROR) << "Failed to set user id, setuid";
return false;
}
return true;
}
示例13: acquire_wake_lock
void TrimTask::run() {
acquire_wake_lock(PARTIAL_WAKE_LOCK, kWakeLock);
for (const auto& path : mPaths) {
LOG(DEBUG) << "Starting trim of " << path;
int fd = open(path.c_str(), O_RDONLY | O_DIRECTORY | O_CLOEXEC | O_NOFOLLOW);
if (fd < 0) {
PLOG(WARNING) << "Failed to open " << path;
continue;
}
struct fstrim_range range;
memset(&range, 0, sizeof(range));
range.len = ULLONG_MAX;
nsecs_t start = systemTime(SYSTEM_TIME_BOOTTIME);
if (ioctl(fd, (mFlags & Flags::kDeepTrim) ? FIDTRIM : FITRIM, &range)) {
PLOG(WARNING) << "Trim failed on " << path;
notifyResult(path, -1, -1);
} else {
nsecs_t delta = systemTime(SYSTEM_TIME_BOOTTIME) - start;
LOG(INFO) << "Trimmed " << range.len << " bytes on " << path
<< " in " << nanoseconds_to_milliseconds(delta) << "ms";
notifyResult(path, range.len, delta);
}
close(fd);
if (mFlags & Flags::kBenchmarkAfter) {
#if BENCHMARK_ENABLED
BenchmarkPrivate(path);
#else
LOG(DEBUG) << "Benchmark disabled";
#endif
}
}
release_wake_lock(kWakeLock);
}
示例14: generate_verity_tree
bool generate_verity_tree(const std::string& data_filename,
const std::string& verity_filename,
HashTreeBuilder* builder,
const std::vector<unsigned char>& salt_content,
size_t block_size, bool sparse, bool verbose) {
android::base::unique_fd data_fd(open(data_filename.c_str(), O_RDONLY));
if (data_fd == -1) {
PLOG(ERROR) << "failed to open " << data_filename;
return false;
}
struct sparse_file* file;
if (sparse) {
file = sparse_file_import(data_fd, false, false);
} else {
file = sparse_file_import_auto(data_fd, false, verbose);
}
if (!file) {
LOG(ERROR) << "failed to read file " << data_filename;
return false;
}
int64_t len = sparse_file_len(file, false, false);
if (len % block_size != 0) {
LOG(ERROR) << "file size " << len << " is not a multiple of " << block_size
<< " byte";
return false;
}
// Initialize the builder to compute the hash tree.
if (!builder->Initialize(len, salt_content)) {
LOG(ERROR) << "Failed to initialize HashTreeBuilder";
return false;
}
auto hash_callback = [](void* priv, const void* data, size_t len) {
auto sparse_hasher = static_cast<HashTreeBuilder*>(priv);
return sparse_hasher->Update(static_cast<const unsigned char*>(data), len)
? 0
: 1;
};
sparse_file_callback(file, false, false, hash_callback, builder);
sparse_file_destroy(file);
if (!builder->BuildHashTree()) {
return false;
}
return builder->WriteHashTreeToFile(verity_filename);
}
示例15: WDT_CHECK
int64_t WdtSocket::ioWithAbortCheck(F readOrWrite, T tbuf, int64_t numBytes,
int timeoutMs, bool tryFull) {
WDT_CHECK(threadCtx_.getAbortChecker() != nullptr)
<< "abort checker can not be null";
bool checkAbort = (threadCtx_.getOptions().abort_check_interval_millis > 0);
auto startTime = Clock::now();
int64_t doneBytes = 0;
int retries = 0;
while (doneBytes < numBytes) {
const int64_t ret =
readOrWrite(fd_, tbuf + doneBytes, numBytes - doneBytes);
if (ret < 0) {
// error
if (errno != EINTR && errno != EAGAIN) {
PLOG(ERROR) << "non-retryable error encountered during socket io "
<< fd_ << " " << doneBytes << " " << retries;
return (doneBytes > 0 ? doneBytes : ret);
}
} else if (ret == 0) {
// eof
VLOG(1) << "EOF received during socket io. fd : " << fd_
<< ", finished bytes : " << doneBytes
<< ", retries : " << retries;
return doneBytes;
} else {
// success
doneBytes += ret;
if (!tryFull) {
// do not have to read/write entire data
return doneBytes;
}
}
if (checkAbort && threadCtx_.getAbortChecker()->shouldAbort()) {
LOG(ERROR) << "transfer aborted during socket io " << fd_ << " "
<< doneBytes << " " << retries;
return (doneBytes > 0 ? doneBytes : -1);
}
if (timeoutMs > 0) {
int duration = durationMillis(Clock::now() - startTime);
if (duration >= timeoutMs) {
LOG(INFO) << "socket io timed out after " << duration << " ms, retries "
<< retries << " fd " << fd_ << " doneBytes " << doneBytes;
return (doneBytes > 0 ? doneBytes : -1);
}
}
retries++;
}
VLOG_IF(1, retries > 1) << "socket io for " << doneBytes << " bytes took "
<< retries << " retries";
return doneBytes;
}