示例#1
0
	void log_function(boost::shared_ptr<std::ostream> os, fscp::log_level level, const std::string& msg, const boost::posix_time::ptime& timestamp = boost::posix_time::microsec_clock::local_time())
	{
		if (os)
		{
			(*os) << boost::posix_time::to_iso_extended_string(timestamp) << " [" << log_level_to_string(level) << "] " << msg << std::endl;
		}
	}
示例#2
0
std::string log_level_to_string_extended(fscp::log_level level)
{
#ifdef WINDOWS
	// No color support on Windows.
	return log_level_to_string(level);
#else
	if (!DISABLE_COLOR && ::isatty(STDOUT_FILENO))
	{
		// This is a terminal, we probably have color support.
		return log_level_to_color(level) + log_level_to_string(level) + COLOR_RESET;
	}
	else
	{
		return log_level_to_string(level);
	}
#endif
}
示例#3
0
文件: lua_log.c 项目: laino/MudCore
static gint lua_log_index(lua_State* lua) {
  if (lua_type(lua, 2) == LUA_TSTRING
      && strcmp(lua_tostring(lua, 2), "level") == 0) {
    lua_pushstring(lua, log_level_to_string(log_get_level()));
  } else {
    lua_pushnil(lua);
  }
  return 1;
}
示例#4
0
static char *
dump_logs(void)
{
  smartlist_t *msgs;
  char *out;
  if (! messages)
    return tor_strdup("");
  msgs = smartlist_new();
  SMARTLIST_FOREACH_BEGIN(messages, logmsg_t *, x) {
    smartlist_add_asprintf(msgs, "[%s] %s",
                           log_level_to_string(x->severity), x->msg);
  } SMARTLIST_FOREACH_END(x);
示例#5
0
static void
debug_dialog_add_message (EmpathyDebugDialog *debug_dialog,
    gdouble timestamp,
    const gchar *domain_category,
    guint level,
    const gchar *message)
{
  EmpathyDebugDialogPriv *priv = GET_PRIV (debug_dialog);
  gchar *domain, *category;
  GtkTreeIter iter;
  gchar *string;

  if (g_strrstr (domain_category, "/"))
    {
      gchar **parts = g_strsplit (domain_category, "/", 2);
      domain = g_strdup (parts[0]);
      category = g_strdup (parts[1]);
      g_strfreev (parts);
    }
  else
    {
      domain = g_strdup (domain_category);
      category = g_strdup ("");
    }

  if (g_str_has_suffix (message, "\n"))
    string = g_strchomp (g_strdup (message));
  else
    string = g_strdup (message);


  gtk_list_store_append (priv->store, &iter);
  gtk_list_store_set (priv->store, &iter,
      COL_DEBUG_TIMESTAMP, timestamp,
      COL_DEBUG_DOMAIN, domain,
      COL_DEBUG_CATEGORY, category,
      COL_DEBUG_LEVEL_STRING, log_level_to_string (level),
      COL_DEBUG_MESSAGE, string,
      COL_DEBUG_LEVEL_VALUE, level,
      -1);

  g_free (string);
  g_free (domain);
  g_free (category);
}
示例#6
0
static void log_sink_file_log_message (log_sink_file_t *sink, log_level_t level, const char *source, const char *message)
{
       fprintf (sink->file, "%s: [%s]: %s", log_level_to_string (level), source, message);
}
示例#7
0
文件: main.cpp 项目: shazz/freelan
void do_log(freelan::log_level level, const std::string& msg)
{
	std::cout << boost::posix_time::to_iso_extended_string(boost::posix_time::microsec_clock::local_time()) << " [" << log_level_to_string(level) << "] " << msg << std::endl;
}