本文整理汇总了C++中LogCategory类的典型用法代码示例。如果您正苦于以下问题:C++ LogCategory类的具体用法?C++ LogCategory怎么用?C++ LogCategory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了LogCategory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: gglCreateDisplay
GLDisplay gglCreateDisplay(::Display* display,int screen)
{
// Load and bind DLL functions
if (!_hGL) {
static LogCategory log("/Gfx/Device/GL");
_hGL = LoadLibrary("libGL.so");
if (!_hGL) {
log.print("GLDevice: OpenGL dll failed to load");
return false;
}
if (!gglBindCoreFunctions(_hGL.ptr(),&_LibraryFunctions)) {
log.print("GLDevice: Failed to bind all core functions");
return false;
}
_GGLptr = &_LibraryFunctions;
log.print("OpenGL library loaded");
}
//
GGLDisplay* dp = new GGLDisplay;
dp->display = display;
dp->screen = screen;
gglBindGLX(display,screen,&dp->glx);
return dp;
}
示例2: createCategoryLocked
LogCategory* LoggerDB::createCategoryLocked(
LoggerNameMap& loggersByName,
StringPiece name,
LogCategory* parent) {
auto uptr = std::make_unique<LogCategory>(name, parent);
LogCategory* logger = uptr.get();
auto ret = loggersByName.emplace(logger->getName(), std::move(uptr));
DCHECK(ret.second);
return logger;
}
示例3: DatabaseServer
DatabaseServer(RoleConfig roleconfig) : Role(roleconfig),
m_db_engine(DBEngineFactory::singleton.instantiate(
engine_type.get_rval(roleconfig),
roleconfig["engine"],
min_id.get_rval(roleconfig),
max_id.get_rval(roleconfig))),
m_control_channel(control_channel.get_rval(roleconfig)),
m_min_id(min_id.get_rval(roleconfig)),
m_max_id(max_id.get_rval(roleconfig))
{
// Initialize DatabaseServer log
std::stringstream log_title;
log_title << "Database(" << m_control_channel << ")";
m_log = new LogCategory("db", log_title.str());
// Check to see the engine was instantiated
if(!m_db_engine)
{
m_log->fatal() << "No database engine of type '" << engine_type.get_rval(roleconfig) << "' exists." << std::endl;
exit(1);
}
// Listen on control channel
subscribe_channel(m_control_channel);
}
示例4: load
inline bool load(doid_t do_id, YAML::Node &document)
{
ifstream stream(filename(do_id));
document = YAML::Load(stream);
if(!document.IsDefined() || document.IsNull())
{
m_log->error() << "obj-" << do_id << " does not exist in database." << endl;
return false;
}
if(!document["class"].IsDefined() || document["class"].IsNull())
{
m_log->error() << filename(do_id) << " does not contain the 'class' key." << endl;
return false;
}
if(!document["fields"].IsDefined() || document["fields"].IsNull())
{
m_log->error() << filename(do_id) << " does not contain the 'fields' key." << endl;
return false;
}
// Read object's DistributedClass
string dc_name = document["class"].as<string>();
if(!g_dcf->get_class_by_name(dc_name))
{
m_log->error() << "Class '" << dc_name << "', loaded from '" << filename(do_id)
<< "', does not exist." << endl;
return false;
}
return true;
}
示例5: set_field
void set_field(doid_t do_id, const Field* field, const val_t &value)
{
m_log->trace() << "Setting field on obj-" << do_id << endl;
YAML::Node document;
if(!load(do_id, document))
{
return;
}
// Get the fields from the file that are not being updated
const Class* dcc = g_dcf->get_class_by_name(document["class"].as<string>());
ObjectData dbo(dcc->get_id());
YAML::Node existing = document["fields"];
for(auto it = existing.begin(); it != existing.end(); ++it)
{
const Field* field = dcc->get_field_by_name(it->first.as<string>());
if(!field)
{
m_log->warning() << "Field '" << it->first.as<string>()
<< "', loaded from '" << filename(do_id)
<< "', does not exist." << endl;
continue;
}
vector<uint8_t> value = read_yaml_field(field, it->second, do_id);
if(value.size() > 0)
{
dbo.fields[field] = value;
}
}
dbo.fields[field] = value;
write_yaml_object(do_id, dcc, dbo);
}
示例6: get_fields
bool get_fields(doid_t do_id, const vector<const Field*> &fields, map_t &values)
{
m_log->trace() << "Getting fields on obj-" << do_id << endl;
YAML::Node document;
if(!load(do_id, document))
{
return false;
}
// Get the fields from the file that are not being updated
for(auto it = fields.begin(); it != fields.end(); ++it)
{
const Field* field = *it;
m_log->trace() << "Searching for field: " << field->get_name() << endl;
YAML::Node existing = document["fields"];
for(auto it2 = existing.begin(); it2 != existing.end(); ++it2)
{
if(it2->first.as<string>() == field->get_name())
{
vector<uint8_t> value = read_yaml_field(field, it2->second, do_id);
if(value.size() > 0)
{
values[*it] = value;
m_log->trace() << "Found requested field: " + field->get_name() << endl;
}
}
}
}
return true;
}
示例7: handle_delete
void handle_delete(DBClientBase *client, DBOperation *operation)
{
BSONObj result;
bool success;
try {
success = client->runCommand(
m_db,
BSON("findandmodify" << "astron.objects" <<
"query" << BSON(
"_id" << operation->doid()) <<
"remove" << true),
result);
} catch(mongo::DBException &e) {
m_log->error() << "Unexpected error while deleting "
<< operation->doid() << ": " << e.what() << endl;
operation->on_failure();
return;
}
m_log->trace() << "handle_delete: got response: "
<< result << endl;
// If the findandmodify command failed, there wasn't anything there
// to delete in the first place.
if(!success || result["value"].isNull()) {
m_log->error() << "Tried to delete non-existent doid "
<< operation->doid() << endl;
operation->on_failure();
return;
}
free_doid(client, operation->doid());
operation->on_complete();
}
示例8: assign_doid_reuse
// This is used when the monotonic counter is exhausted:
doid_t assign_doid_reuse(DBClientBase *client)
{
BSONObj result;
bool success = client->runCommand(
m_db,
BSON("findandmodify" << "astron.globals" <<
"query" << BSON(
"_id" << "GLOBALS" <<
"doid.free.0" << BSON("$exists" << true)
) <<
"update" << BSON(
"$pop" << BSON("doid.free" << -1)
)), result);
// If the findandmodify command failed, the document either doesn't
// exist, or we ran out of reusable doids.
if(!success || result["value"].isNull()) {
m_log->error() << "Could not allocate a reused DOID!" << endl;
return INVALID_DO_ID;
}
m_log->trace() << "assign_doid_reuse: got globals element: "
<< result << endl;
// Otherwise, use the first one:
doid_t doid;
const BSONElement &element = result["value"]["doid"]["free"];
if(sizeof(doid) == sizeof(long long)) {
doid = element.Array()[0].Long();
} else if(sizeof(doid) == sizeof(int)) {
doid = element.Array()[0].Int();
}
return doid;
}
示例9: handle_get
void handle_get(DBClientBase *client, DBOperation *operation)
{
BSONObj obj;
try {
obj = client->findOne(m_obj_collection,
BSON("_id" << operation->doid()));
} catch(mongo::DBException &e) {
m_log->error() << "Unexpected error occurred while trying to"
" retrieve object with DOID "
<< operation->doid() << ": " << e.what() << endl;
operation->on_failure();
return;
}
if(obj.isEmpty()) {
m_log->warning() << "Got queried for non-existent object with DOID "
<< operation->doid() << endl;
operation->on_failure();
return;
}
DBObjectSnapshot *snap = format_snapshot(operation->doid(), obj);
if(!snap || !operation->verify_class(snap->m_dclass)) {
operation->on_failure();
} else {
operation->on_complete(snap);
}
}
示例10: get_field
bool get_field(doid_t do_id, const Field* field, val_t &value)
{
m_log->trace() << "Getting field on obj-" << do_id << endl;
YAML::Node document;
if(!load(do_id, document))
{
return false;
}
// Get the fields from the file that are not being updated
YAML::Node node = document["fields"][field->get_name()];
if(!node.IsDefined() || node.IsNull())
{
return false;
}
m_log->trace() << "Found requested field: " + field->get_name() << endl;
value = read_yaml_field(field, node, do_id);
if(value.size() > 0)
{
return true;
}
return false;
}
示例11: check_class
void check_class(uint16_t id, string name, unsigned long hash)
{
DCClass* dcc = g_dcf->get_class(id);
if(name != dcc->get_name())
{
// TODO: Try and update the database instead of exiting
m_log->fatal() << "Class name '" << dcc->get_name() << "' from DCFile does not match"
" name '" << name << "' in database, for dc_id " << id << endl;
m_log->fatal() << "Database must be rebuilt." << endl;
exit(1);
}
HashGenerator gen;
dcc->generate_hash(gen);
if(hash != gen.get_hash())
{
// TODO: Try and update the database instead of exiting
m_log->fatal() << "Class hash '" << gen.get_hash() << "' from DCFile does not match"
" hash '" << hash << "' in database, for dc_id " << id << endl;
m_log->fatal() << "Database must be rebuilt." << endl;
exit(1);
}
// TODO: Check class_fields table exists
}
示例12: validate
bool ConfigGroup::validate(ConfigNode node)
{
if(!node.IsMap())
{
if(m_name.length() > 0)
{
config_log.error() << "Section '" << m_path
<< "' has key/value config variables.\n";
}
else
{
config_log.error() << "Config sections must be at root of config file.\n";
}
return false;
}
bool ok = true;
for(auto it = node.begin(); it != node.end(); ++it)
{
string key = it->first.as<std::string>();
auto found_var = m_variables.find(key);
if(found_var != m_variables.end())
{
rtest r = found_var->second;
if(!r(node))
{
config_log.info() << "In Section '" << m_path << "', attribute '"
<< key << "' did not match constraint (see error).\n";
ok = false;
}
continue;
}
auto found_grp = m_children.find(key);
if(found_grp != m_children.end())
{
if(!found_grp->second->validate(node[key]))
{
ok = false;
}
continue;
}
if(m_name.length() > 0)
{
config_log.error() << "Section '" << m_path
<< "' has no attribute named '" << key << "'.\n";
}
else
{
config_log.error() << "Section '" << key << "' is not a valid config category.\n";
}
ok = false;
}
return ok;
}
示例13: handle_create
void handle_create(DBClientBase *client, DBOperation *operation)
{
// First, let's convert the requested object into BSON; this way, if
// a failure happens, it happens before we waste a doid.
BSONObjBuilder fields;
try {
for(auto it = operation->set_fields().begin();
it != operation->set_fields().end();
++it) {
DatagramPtr dg = Datagram::create();
dg->add_data(it->second);
DatagramIterator dgi(dg);
fields << it->first->get_name()
<< bamboo2bson(it->first->get_type(), dgi)["_"];
}
} catch(mongo::DBException &e) {
m_log->error() << "While formatting "
<< operation->dclass()->get_name()
<< " for insertion: " << e.what() << endl;
operation->on_failure();
return;
}
doid_t doid = assign_doid(client);
if(doid == INVALID_DO_ID) {
// The error will already have been emitted at this point, so
// all that's left for us to do is fail silently:
operation->on_failure();
return;
}
BSONObj b = BSON("_id" << doid <<
"dclass" << operation->dclass()->get_name() <<
"fields" << fields.obj());
m_log->trace() << "Inserting new " << operation->dclass()->get_name()
<< "(" << doid << "): " << b << endl;
try {
client->insert(m_obj_collection, b);
} catch(mongo::DBException &e) {
m_log->error() << "Cannot insert new "
<< operation->dclass()->get_name()
<< "(" << doid << "): " << e.what() << endl;
operation->on_failure();
return;
}
operation->on_complete(doid);
}
示例14: setup
void setup()
{
mdperf_log.info() << "Creating random data..." << std::endl;
data = new uint8_t[MD_PERF_DATASIZE];
data[0] = MD_PERF_NUM_DEST_CHANNELS;
for(uint32_t i = 1; i < MD_PERF_DATASIZE; ++i) {
data[i] = rand() % 256;
}
mdperf_log.info() << "Creating MDPerformanceParticipants" << std::endl;
m_participants = new MDPerformanceParticipant*[MD_PERF_NUM_PARTICIPANTS];
for(uint32_t i = 0; i < MD_PERF_NUM_PARTICIPANTS; ++i) {
m_participants[i] = new MDPerformanceParticipant;
}
}
示例15: check_class
void check_class(uint16_t id, string name)
{
const Class* dcc = g_dcf->get_class_by_id(id);
if(name != dcc->get_name()) {
// TODO: Try and update the database instead of exiting
m_log->fatal() << "Class name '" << dcc->get_name() << "' from File does not match"
" name '" << name << "' in database, for dc_id " << id << endl;
m_log->fatal() << "Database must be rebuilt." << endl;
astron_shutdown(1);
}
// TODO: Check class_fields table exists
}