Ion
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
logging_nacl.cc
Go to the documentation of this file.
1
18
#include <iostream>
// NOLINT
19
#include <sstream>
20
21
#include "ppapi/c/ppb_console.h"
22
#include "ppapi/cpp/instance.h"
23
#include "ppapi/cpp/module.h"
24
#include "ppapi/cpp/var.h"
25
26
#include "
ion/port/logging.h
"
27
28
namespace
pp {
29
class
Instance;
30
}
// namespace pp
31
32
namespace
{
33
34
static
PP_LogLevel GetPPLogLevelFromSeverity(
ion::port::LogSeverity
severity) {
35
switch
(severity) {
36
case
ion::port::INFO
:
37
return
PP_LOGLEVEL_LOG;
38
case
ion::port::WARNING
:
39
return
PP_LOGLEVEL_WARNING;
40
case
ion::port::ERROR
:
41
case
ion::port::FATAL
:
42
case
ion::port::DFATAL
:
43
return
PP_LOGLEVEL_ERROR;
44
}
45
}
46
49
class
NaClLogEntryWriter :
public
ion::port::LogEntryWriter
{
50
public
:
51
NaClLogEntryWriter() {}
52
virtual
~NaClLogEntryWriter() {}
53
55
virtual
void
Write(
ion::port::LogSeverity
severity,
56
const
std::string& message) {
58
pp::Module* module = pp::Module::Get();
59
if
(module) {
60
PP_LogLevel
level
= GetPPLogLevelFromSeverity(severity);
61
const
pp::Module::InstanceMap& instances = module->current_instances();
62
for
(pp::Module::InstanceMap::const_iterator iter = instances.begin();
63
iter != instances.end(); ++iter) {
64
pp::Instance* instance = iter->second;
65
if
(instance) {
66
instance->LogToConsole(level, message);
67
}
68
}
69
}
70
72
std::cerr << GetSeverityName(severity) <<
" "
<< message << std::endl;
73
}
74
};
75
76
}
// namespace
77
78
ion::port::LogEntryWriter
*
ion::port::CreateDefaultLogEntryWriter
() {
79
return
new
NaClLogEntryWriter();
80
}
logging.h
ion::port::LogEntryWriter
Abstract class which can be overridden to integrate Ion logging with other logging systems...
Definition:
logging.h:36
level
int level
Definition:
tracinghandler.cc:71
ion::port::INFO
Definition:
logging.h:27
ion::port::LogSeverity
LogSeverity
Definition:
logging.h:26
ion::port::DFATAL
Definition:
logging.h:31
ion::port::ERROR
Definition:
logging.h:29
ion::port::WARNING
Definition:
logging.h:28
ion::port::FATAL
Definition:
logging.h:30
ion::port::CreateDefaultLogEntryWriter
ION_API LogEntryWriter * CreateDefaultLogEntryWriter()
Instantiate a new LogEntryWriter of the default type for the current platform...
Definition:
logging_android.cc:87
port
logging_nacl.cc
Generated by
1.8.6