Postgres log_line_prefix 设置日志输出格式 log_line_prefix 设置日志输出格式

log_line_prefix 设置日志输出格式

log_line_prefix 设置日志输出格式(能够记录时间,用户名称,数据库名称,客户端IP和端口,方便定位问题)

日志:  语句:alter system set log_line_prefix = '%m %p %u %d %r ';

日志:  执行时间: 11.410 ms

日志:  断开连接: 会话时间: 0:03:21.173 user=highgodatabase=highgo host=[local]

日志:  接收到SIGHUP, 重载配置文件

2017-04-04 16:11:06.631 CST 1919    日志:  参数"log_line_prefix"被改为"%m %p %u %d %r"

2017-04-04 16:11:09.464 CST 1995 [未知] [未知] [local] 日志:  已接收到连接: 主机=[local]

2017-04-04 16:11:09.467 CST 1995 highgohighgo [local] 日志:  联接认证: 主机=highgo 数据库=highgo

2017-04-04 16:12:55.255 CST 1995 highgohighgo [local] 日志:  语句: insert into testvalues (3);

2017-04-0416:12:55.257 CST 1995 highgo highgo [local] 日志:  执行时间: 2.165 ms
  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
struct SMS { int index; std::string state; std::string sender; std::string timestamp; std::string message; }; std::vector<SMS> smsList; bool serial_port::serial_port_write_read_at_bySMS(const std::string &at_command, const std::string &resp_prefix, std::vector<SMS>& smsList) { std::vector<std::string> read_lines; bool ret_value = false; pthread_mutex_lock(&read_write_mutex); if (!serial_port_write_at_cmd(at_command.c_str())) { goto END; } int index = -1 while (true) { int n = -1; char state[32] = {}, phone_num[32] = {}, phone_time[64] = {}; read_lines = serial_port_read_multiple_lines(); for (size_t i = 0; i < read_lines.size(); i++) { //LOG_F(INFO, "read one line from serial: %s", read_lines[i].c_str()); if (read_lines[i] == "AT" || read_lines[i] == "at") { //Do nothing } else if (read_lines[i] == "OK") { //LOG_F(INFO, "find final response OK"); ret_value = true; break; } else if (read_lines[i] == "ERROR" || read_lines[i] == "+CME ERROR") { //LOG_F(INFO, "find final response ERROR"); ret_value = false; break; } else if (read_lines[i].find("+CMGL") != std::string::npos) { LOG_F(INFO, "response_data[%zu]: %s", i, read_lines[i].c_str()); sscanf(read_lines[i].c_str(), R"(+CMGL: %d,"%s","%s","%s")", &n, state, phone_num, phone_time); LOG_F(INFO, "n: %d, state: %s, phone_num: %s, phone_time: %s", n, state, phone_num, phone_time); SMS sms; index = i; sms.index = index; sms.state = state; sms.sender = phone_num; sms.timestamp = phone_time; if (i + 1 < read_lines.size() && read_lines[i + 1].find('\n') != std::string::npos) { sms.message = read_lines[i+1]; index = i + 1; // 设置索引为下一个未读取的响应行的索引 } smsList.push_back(sms); } else { LOG_F(INFO, "response_data[%zu]->message: %s", i, read_lines[i].c_str()); // 继续往下读一行 } } if (index == -1) { break; // 未找到新的响应,退出循环 } } END: pthread_mutex_unlock(&read_write_mutex); return ret_value; } 如果要调用这个api应该怎么写
07-16
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值