MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / trace_create

Method trace_create

src/utilities/ntrace/traceplugin.cpp:53–106  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

51}
52
53Firebird::ITracePlugin* TraceFactoryImpl::trace_create(Firebird::CheckStatusWrapper* status,
54 Firebird::ITraceInitInfo* initInfo)
55{
56 Firebird::MasterInterfacePtr master;
57 const char* dbname = NULL;
58 try
59 {
60 dbname = initInfo->getDatabaseName();
61 if (!dbname)
62 dbname = "";
63
64 TracePluginConfig config;
65 TraceCfgReader::readTraceConfiguration(initInfo->getConfigText(), dbname, config);
66
67 Firebird::ITraceDatabaseConnection* connection = initInfo->getConnection();
68
69 if (!config.enabled ||
70 (config.connection_id && connection &&
71 (connection->getConnectionID() != config.connection_id)))
72 {
73 return NULL; // Plugin is not needed, no error happened.
74 }
75
76 Firebird::AutoPtr<Firebird::ITraceLogWriter, Firebird::SimpleRelease>
77 logWriter(initInfo->getLogWriter());
78
79 if (logWriter)
80 config.log_filename = "";
81
82 return FB_NEW TracePluginImpl(this, config, initInfo); // Everything is ok, we created a plugin
83
84 }
85 catch (Firebird::Exception& ex)
86 {
87 // put error into trace log
88 Firebird::ITraceLogWriter* logWriter = initInfo->getLogWriter();
89 if (logWriter)
90 {
91 const char* strEx = TracePluginImpl::marshal_exception(ex);
92 Firebird::string err;
93 if (dbname && dbname[0])
94 err.printf("Error creating trace session for database \"%s\":\n%s\n", dbname, strEx);
95 else
96 err.printf("Error creating trace session for service manager attachment:\n%s\n", strEx);
97
98 logWriter->write(err.c_str(), err.length());
99 logWriter->release();
100 }
101 else
102 ex.stuffException(status);
103 }
104
105 return NULL;
106}
107
108
109static Firebird::SimpleFactory<TraceFactoryImpl> traceFactory;

Callers 1

update_sessionMethod · 0.45

Calls 12

TracePluginImplClass · 0.85
getDatabaseNameMethod · 0.45
getConfigTextMethod · 0.45
getConnectionMethod · 0.45
getConnectionIDMethod · 0.45
getLogWriterMethod · 0.45
printfMethod · 0.45
writeMethod · 0.45
c_strMethod · 0.45
lengthMethod · 0.45
releaseMethod · 0.45
stuffExceptionMethod · 0.45

Tested by

no test coverage detected