我在我的程序中使用boost.log,默认格式化程序以十六进制格式输出ProcessID和ThreadID,任何人都知道如何以dec格式打印它们,谢谢.
这是我的代码的github:https://github.com/owenliang/boost_asio,谢谢.
boost::log::formatter scope_formatter = boost::log::expressions::stream << "[" <<
boost::log::expressions::format_date_time<boost::posix_time::ptime>("TimeStamp", "%Y-%m-%d %H:%M:%S") <<
"] [" << boost::log::expressions::attr<boost::log::attributes::current_process_id::value_type>("ProcessID") <<
"-" << boost::log::expressions::attr<boost::log::attributes::current_thread_id::value_type>("ThreadID") << "] [" <<
boost::log::expressions::attr<boost::log::trivial::severity_level>("Severity") <<
"] " << boost::log::expressions::format_named_scope("Scope", boost::log::keywords::format = "%c[%F:%l] ",
boost::log::keywords::depth = 1) << boost::log::expressions::smessage;
Run Code Online (Sandbox Code Playgroud) 这是uwsgi配置:
[uwsgi]
uid = 500
listen=200
master = true
profiler = true
processes = 8
logdate = true
socket = 127.0.0.1:8000
module = www.wsgi
pythonpath = /root/www/
pythonpath = /root/www/www
pidfile = /root/www/www.pid
daemonize = /root/www/www.log
enable-threads = true
memory-report = true
limit-as = 6048
Run Code Online (Sandbox Code Playgroud)
这是Nginx配置:
server{
listen 80;
server_name 119.254.35.221;
location / {
uwsgi_pass 127.0.0.1:8000;
include uwsgi_params;
}
}
Run Code Online (Sandbox Code Playgroud)
django工作正常,但除非我重新启动uwsgi,否则无法看到修改后的页面.(更重要的是,当我配置8个工作进程时,我可以看到修改后的页面,当我按住ctrl + f5一段时间后,似乎只能确定worker可以读取并响应修改后的页面,但是其他人只显示旧的,缓存旧页面的内容?我没有配置任何有关缓存的内容)
我没有配置django,它适用于"python manager runserver ...",但在使用nginx + uwsgi时遇到了这个问题.
(nginx和uwsgi都是新安装,我相信这里没有任何其他内容......)
我最近用5.2学习,我想尝试这样做:
步骤1,为lua构建交流模块:
#include "lua.h"
#include "lauxlib.h"
#include "lualib.h"
#include <stdlib.h>
static int add(lua_State *L) {
int x = luaL_checkint(L, -2);
int y = luaL_checkint(L, -1);
lua_pushinteger(L, x + y);
return 1;
}
static const struct luaL_Reg reg_lib[] = {
{"add", add}
};
int luaopen_tool(lua_State *L) {
luaL_newlib(L, reg_lib);
lua_setglobal(L, "tool");
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我用liblua.a编译并链接它,我确信它在lua脚本中运行良好,例如"require("tool")tool.add(1,2)"
第2步,我写了另一个想要在步骤1中要求我的c模块的C程序,如下所示:
#include "lua.h"
#include "lauxlib.h"
#include "lualib.h"
#include <stdlib.h>
int main(int argc, char* const argv[]) {
lua_State *L = luaL_newstate();
luaL_requiref(L, "base", luaopen_base, 1);
luaL_requiref(L, "package", …
Run Code Online (Sandbox Code Playgroud)