Browse Source

Add flushing of log file

merge-requests/365/head
Jørgen Lien Sellæg 11 years ago
parent
commit
96b863e488
  1. 5
      juci/api.cc
  2. 11
      juci/juci.cc
  3. 18
      juci/logging.h
  4. 4
      juci/source.cc

5
juci/api.cc

@ -1,4 +1,5 @@
#include "api.h" #include "api.h"
#include "logging.h"
Menu::Controller* PluginApi::menu_; Menu::Controller* PluginApi::menu_;
Notebook::Controller* PluginApi::notebook_; Notebook::Controller* PluginApi::notebook_;
@ -13,8 +14,6 @@ PluginApi::PluginApi(Menu::Controller& menu_ctl_,
} }
PluginApi::~PluginApi() { PluginApi::~PluginApi() {
delete menu_;
delete notebook_;
menu_ = NULL; menu_ = NULL;
notebook_ = NULL; notebook_ = NULL;
} }
@ -39,7 +38,7 @@ void PluginApi::ReplaceWord(std::string word) {
} }
void PluginApi::ReplaceLine(std::string line) { void PluginApi::ReplaceLine(std::string line) {
std::cout << "unimplemented: " << __func__ << std::endl; WARNING("use of unimplemented method");
} }
std::string PluginApi::GetWord() { std::string PluginApi::GetWord() {

11
juci/juci.cc

@ -1,14 +1,19 @@
#include "window.h" #include "window.h"
#include "logging.h" #include "logging.h"
void init_logging() {
add_common_attributes();
add_file_log(keywords::file_name = "juci.log",
keywords::auto_flush = true);
INFO("Logging initalized");
}
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
Glib::RefPtr<Gtk::Application> app = Gtk::Application::create( Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(
argc, argc,
argv, argv,
"no.sout.juci"); "no.sout.juci");
init_logging();
add_file_log("juci.log");
INFO("Logging initalized");
Window window; Window window;
return app->run(window); return app->run(window);
} }

18
juci/logging.h

@ -12,11 +12,17 @@
using namespace boost::log; using namespace boost::log;
#define TRACE(x) BOOST_LOG_TRIVIAL(trace) << __func__ << "(" << __LINE__ << "): " << #x << "=<" << x << ">"; #define TRACE_VAR(x) BOOST_LOG_TRIVIAL(trace) << "** Trace: " << __FILE__ << "@" << __func__ << "(" << __LINE__ << "): " << #x << "=<" << x << ">";
#define DEBUG(x) BOOST_LOG_TRIVIAL(debug) << __func__ << "(" << __LINE__ << "): " << #x << "=<" << x << ">"; #define DEBUG_VAR(x) BOOST_LOG_TRIVIAL(debug) << "** Debug: " << __FILE__ << "@" << __func__ << "(" << __LINE__ << "): " << #x << "=<" << x << ">";
#define INFO(x) BOOST_LOG_TRIVIAL(info) << __func__ << "(" << __LINE__ << "): \"" x << "\""; #define INFO_VAR(x) BOOST_LOG_TRIVIAL(info) << "** Info: " << __FILE__ << "@" << __func__ << "(" << __LINE__ << "): " << #x << "=<" << x << ">";
#define WARNING(x) BOOST_LOG_TRIVIAL(warning) << __func__ << "(" << __LINE__ << "): " << #x << "=<" << x << ">"; #define WARNING_VAR(x) BOOST_LOG_TRIVIAL(warning) << "** Warning: " << __FILE__ << "@" << __func__ << "(" << __LINE__ << "): " << #x << "=<" << x << ">";
#define ERROR(x) BOOST_LOG_TRIVIAL(error) << __func__ << "(" << __LINE__ << "): " << #x << "=<" << x << ">"; #define FATAL_VAR(x) BOOST_LOG_TRIVIAL(fatal) << "** Fatal: " << __FILE__ << "@" << __func__ << "(" << __LINE__ << "): " << #x << "=<" << x << ">";
#define FATAL(x) BOOST_LOG_TRIVIAL(fatal) << __func__ << "(" << __LINE__ << "): " << #x << "=<" << x << ">"; #define ERROR_VAR(x) BOOST_LOG_TRIVIAL(error) << "** Error: " << __FILE__ << "@" << __func__ << "(" << __LINE__ << "): " << #x << "=<" << x << ">";
#define TRACE(x) BOOST_LOG_TRIVIAL(trace) << "** Trace: " << __FILE__ << "@" << __func__ << "(" << __LINE__ << "): \"" << x << "\"";
#define DEBUG(x) BOOST_LOG_TRIVIAL(debug) << "** Debug: " << __FILE__ << "@" << __func__ << "(" << __LINE__ << "): \"" << x << "\"";
#define INFO(x) BOOST_LOG_TRIVIAL(info) << "** Info: " << __FILE__ << "@" << __func__ << "(" << __LINE__ << "): \"" << x << "\"";
#define WARNING(x) BOOST_LOG_TRIVIAL(warning) << "** Warning: " << __FILE__ << "@" << __func__ << "(" << __LINE__ << "): \"" << x << "\"";
#define FATAL(x) BOOST_LOG_TRIVIAL(fatal) << "** Fatal: " << __FILE__ << "@" << __func__ << "(" << __LINE__ << "): \"" << x << "\"";
#define ERROR(x) BOOST_LOG_TRIVIAL(error) << "** Error: " << __FILE__ << "@" << __func__ << "(" << __LINE__ << "): \"" << x << "\"";
#endif // JUCI_LOGGING_H_ #endif // JUCI_LOGGING_H_

4
juci/source.cc

@ -362,6 +362,7 @@ void Source::Controller::OnOpenFile(const string &filepath) {
if (!go) { if (!go) {
std::thread parse([this]() { std::thread parse([this]() {
if (parsing.try_lock()) { if (parsing.try_lock()) {
INFO("Starting parsing");
while (true) { while (true) {
const std::string raw = buffer()->get_text().raw(); const std::string raw = buffer()->get_text().raw();
std::map<std::string, std::string> buffers; std::map<std::string, std::string> buffers;
@ -376,6 +377,7 @@ void Source::Controller::OnOpenFile(const string &filepath) {
} }
} }
parsing.unlock(); parsing.unlock();
INFO("Parsing completed");
} }
}); });
parse.detach(); parse.detach();
@ -385,10 +387,12 @@ void Source::Controller::OnOpenFile(const string &filepath) {
buffer()->signal_begin_user_action().connect([this]() { buffer()->signal_begin_user_action().connect([this]() {
if (go) { if (go) {
syntax.lock(); syntax.lock();
INFO("Updating syntax");
view(). view().
OnUpdateSyntax(model().ExtractTokens(0, buffer()->get_text().size()), OnUpdateSyntax(model().ExtractTokens(0, buffer()->get_text().size()),
model().config()); model().config());
go = false; go = false;
INFO("Syntax updated");
syntax.unlock(); syntax.unlock();
} }
}); });

Loading…
Cancel
Save