Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 36 additions & 4 deletions src/utilities/ntrace/TraceConfiguration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,15 @@ void TraceCfgReader::readTraceConfiguration(const char* text,

#define ERROR_PREFIX "error while parsing trace configuration\n\t"

enum class AliasType
{
DETECT,
NAME,
REGEX
};
inline constexpr std::string_view REGEX_PREFIX = "regex ";
inline constexpr std::string_view NAME_PREFIX = "name ";

void TraceCfgReader::readConfig()
{
ConfigFile cfgFile(ConfigFile::USE_TEXT, m_text, ConfigFile::HAS_SUB_CONF | ConfigFile::NATIVE_ORDER
Expand Down Expand Up @@ -127,18 +136,41 @@ void TraceCfgReader::readConfig()
}
else if (isDatabase && !m_databaseName.empty())
{
PathName noQuotePattern = pattern.ToPathName();
PathName noQuotePattern;

AliasType specifier = AliasType::DETECT;
const std::string_view patternView(pattern.data(), pattern.length());

// Check for "name" or "regex" specific in the path.
// Compare path in both ways if specifier is not specified
if (patternView.find_first_of(REGEX_PREFIX) == 0)
{
noQuotePattern.assign(pattern.data() + REGEX_PREFIX.length());
specifier = AliasType::REGEX;
}
else if (patternView.find_first_of(NAME_PREFIX) == 0)
{
noQuotePattern.assign(pattern.data() + NAME_PREFIX.length());
specifier = AliasType::NAME;
}
else
{
noQuotePattern = pattern.ToPathName();
}

noQuotePattern.alltrim(" '\'");
PathName expandedName;

if (m_databaseName == noQuotePattern ||
if (specifier != AliasType::REGEX && (m_databaseName == noQuotePattern ||
(expandDatabaseName(noQuotePattern, expandedName, nullptr),
m_databaseName == expandedName) )
m_databaseName == expandedName) ))
{
// Compare by name
match = exactMatch = true;
}
else
else if (specifier != AliasType::NAME)
{
// Compare by regex
bool regExpOk = false;
try
{
Expand Down
85 changes: 46 additions & 39 deletions src/utilities/ntrace/fbtrace.conf
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
# expression which is matched against fully qualified database path name.
#
# For log file name Sed syntax for substitutions is supported.
# I.e. \0 - whole matched string, \1 ... \9 - parenthesis subexpressions.
# I.e. \0 - whole matched string, \1 ... \9 - parenthesis subexpressions.
# \\ is backslash.
#
# String values should be enclosed into double quotes if contains
# String values should be enclosed into double quotes if contains
# spaces embedded, for example:
# log_filename "C:\\Documents and Settings\\Firebird\\My Documents\\trace.log"
# include_filter "Database Stats"
Expand All @@ -24,6 +24,13 @@
# database = (%[\\/](e[[:DIGIT:]]{2}).fdb)
# type
# database = (%[\\/](e[[:DIGIT:]]{{2}}).fdb)
#
# It is also possible to specify exactly what type of database string is expected
# For example:
# database = name /var/dbs/primary-db.fdb
# type
# database = regex (%[\\/](e[[:DIGIT:]]{{2}}).fdb)



database
Expand All @@ -35,72 +42,72 @@ database
# Operations log file name. For use by system audit trace only
#log_filename = name

# Maximum size of log file (megabytes). Used by system audit trace for
# Maximum size of log file (megabytes). Used by system audit trace for
# log's rotation : when current log file reached this limit it is renamed
# using current date and time and new log file is created. Value of zero
# using current date and time and new log file is created. Value of zero
# means that the log file size is unlimited and rotation will never happen.
#max_log_size = 0


# SQL query filters.
# SQL query filters.
#
# Only SQL statements falling under given regular expression are reported
# Only SQL statements falling under given regular expression are reported
# in the log.
#include_filter
#include_filter

# SQL statements falling under given regular expression are NOT reported
# SQL statements falling under given regular expression are NOT reported
# in the log.
#exclude_filter
#exclude_filter


# Put attach/detach log records
# Put attach/detach log records
#log_connections = false

# Trace only given connection id. If zero - trace all connections
# Trace only given connection id. If zero - trace all connections
#connection_id = 0

# Put transaction start/end records
# Put transaction start/end records
#log_transactions = false


# Put sql statement prepare records
# Put sql statement prepare records
#log_statement_prepare = false

# Put sql statement free records
# Put sql statement free records
#log_statement_free = false

# Put sql statement execution start records
# Put sql statement execution start records
#log_statement_start = false
# Put sql statement execution finish\fetch to eof records

# Put sql statement execution finish\fetch to eof records
#log_statement_finish = false


# Put record when stored procedure is being compiled
#log_procedure_compile = false

# Put record when stored procedure is start execution
# Put record when stored procedure is start execution
#log_procedure_start = false

# Put record when stored procedure is finish execution
# Put record when stored procedure is finish execution
#log_procedure_finish = false

# Put record when stored function is being compiled
#log_function_compile = false

# Put record when stored function is start execution
# Put record when stored function is start execution
#log_function_start = false

# Put record when stored function is finish execution
# Put record when stored function is finish execution
#log_function_finish = false

# Put record when trigger is being compiled
#log_trigger_compile = false

# Put trigger execute records
# Put trigger execute records
#log_trigger_start = false

# Put trigger execute records
# Put trigger execute records
#log_trigger_finish = false


Expand Down Expand Up @@ -142,13 +149,13 @@ database
#print_perf = false


# Put blr requests compile/execute records
# Put blr requests compile/execute records
#log_blr_requests = false

# Print blr requests or not
#print_blr = false

# Put dyn requests execute records
# Put dyn requests execute records
#log_dyn_requests = false

# Print dyn requests or not
Expand All @@ -158,27 +165,27 @@ database
# Put xxx_finish record only if its timing exceeds this number of milliseconds
#time_threshold = 100

# Maximum length of SQL string logged
# Maximum length of SQL string logged
#max_sql_length = 300

# Maximum length of blr request logged
# Maximum length of blr request logged
#max_blr_length = 500

# Maximum length of dyn request logged
# Maximum length of dyn request logged
#max_dyn_length = 500

# Maximum length of individual string argument we log
# Maximum length of individual string argument we log
#max_arg_length = 80

# Maximum number of query arguments to put in log
# Maximum number of query arguments to put in log
#max_arg_count = 30
}



# default services section
#
# List of names of currently existing Firebird services (to use with service
# List of names of currently existing Firebird services (to use with service
# filters below) :
# Backup Database
# Restore Database
Expand All @@ -203,27 +210,27 @@ database
# Display User with Admin Info
# Validate Database
#
services
services
{
# Do we trace services events or not
#enabled = false

# Operations log file name. For use by system audit trace only
#log_filename = name

# Maximum size of log file (megabytes). Used by system audit trace for
# log's rotation
# Maximum size of log file (megabytes). Used by system audit trace for
# log's rotation
#max_log_size = 0

# Services filters.
#
# Only services whose names fall under given regular expression are
# Only services whose names fall under given regular expression are
# reported in the log.
#include_filter
#include_filter

# Services whose names fall under given regular expression are NOT
# Services whose names fall under given regular expression are NOT
# reported in the log.
#exclude_filter
#exclude_filter

# Put service attach, detach and start records
#log_services = false
Expand Down Expand Up @@ -265,7 +272,7 @@ database = %[\\/]my_database.fdb


# Enable logging for test.fdb, azk2.fdb and rulez.fdb in any directory
# into log file name matching database name - test.log, azk2.log and
# into log file name matching database name - test.log, azk2.log and
# rulez.log appropriately
#
database = %[\\/](test|azk2|rulez).fdb
Expand Down
Loading