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

Method logMessage

src/jrd/replication/Utils.cpp:98–135  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

96 }
97
98 void logMessage(LogMsgSide side, LogMsgType type,
99 const PathName& database,
100 const string& message)
101 {
102 const time_t now = time(NULL);
103
104 const auto file = os_utils::fopen(m_filename.c_str(), "a");
105 if (file)
106 {
107 if (!lock(file))
108 {
109 fclose(file);
110 return;
111 }
112
113 if (m_error)
114 m_error = false;
115
116 string dbname, text;
117
118 if (database.hasData())
119 dbname.printf("Database: %s\n\t", database.c_str());
120
121 text.printf("\n%s (%s) %s\t%s%s: %s\n",
122 m_hostname.c_str(), LOG_MSG_SIDES[side], ctime(&now),
123 dbname.c_str(), LOG_MSG_TYPES[type], message.c_str());
124
125 fseek(file, 0, SEEK_END);
126 fputs(text.c_str(), file);
127 fclose(file);
128 unlock();
129 }
130 else if (!m_error && !m_error.exchange(true))
131 {
132 gds__log("Failed to open log file \'%s\', errno %d",
133 m_filename.c_str(), errno);
134 }
135 }
136
137 private:
138 bool lock(FILE* file)

Callers 1

logMessageFunction · 0.80

Calls 10

fcloseFunction · 0.85
fseekFunction · 0.85
fputsFunction · 0.85
fopenFunction · 0.50
lockFunction · 0.50
unlockFunction · 0.50
c_strMethod · 0.45
hasDataMethod · 0.45
printfMethod · 0.45
exchangeMethod · 0.45

Tested by

no test coverage detected