Explore Enterprise Education Gitee Premium Gitee AI AI teammates
Fetch the repository succeeded.
Open Source > Development Lib > Programming Language/Scripting Language &&
Donate
Please sign in before you donate.
Scan WeChat QR to Pay
Cancel
Complete
Prompt
Switch to Alipay.
OK
Cancel
13 Star 69 Fork 22

johnsonyl/cpps

Create your Gitee Account
Explore and code with more than 14 million developers,Free private repositories !:)
Sign up
Already have an account? Sign in
文件
master
Branches (1)
Tags (4)
master
v1.0.3-beta
v1.0.3
v1.0.2
v1.0.0
master
Branches (1)
Tags (4)
master
v1.0.3-beta
v1.0.3
v1.0.2
v1.0.0
Clone or Download
Clone/Download
Prompt
To download the code, please copy the following command and execute it in the terminal
To ensure that your submitted code identity is correctly recognized by Gitee, please execute the following command.
When using the SSH protocol for the first time to clone or push code, follow the prompts below to complete the SSH configuration.
1 Generate RSA keys.
2 Obtain the content of the RSA public key and configure it in SSH Public Keys
To use SVN on Gitee, please visit the usage guide
When using the HTTPS protocol, the command line will prompt for account and password verification as follows. For security reasons, Gitee recommends configure and use personal access tokens instead of login passwords for cloning, pushing, and other operations.
Username for 'https://gitee.com': userName
Password for 'https://userName@gitee.com': # Private Token
master
Branches (1)
Tags (4)
master
v1.0.3-beta
v1.0.3
v1.0.2
v1.0.0
cpps
/
libs
/
logging
/
cpps_logging_handler.cpp
cpps
/
libs
/
logging
/
cpps_logging_handler.cpp
cpps_logging_handler.cpp 5.20 KB
Copy Edit Raw Blame History
johnsonyl authored 2023年12月05日 15:09 +08:00 . logging 增加脚本Handler支持。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272
#include "cpps_logging_handler.h"
#include "cpps_logger.h"
#include <sstream>
cpps::usint8 cpps_slevel_to_nlevel(std::string level);
std::string cpps_nlevel_to_slevel(cpps::usint8 level);
namespace cpps
{
std::string cpps_time_time2str(cpps_integer nt);
std::string cpps_io_getfilename(std::string str);
cpps_integer cpps_this_thread_get_id();
cpps_logging_handler::cpps_logging_handler( cpps_logging_handler_type type)
{
handler_type = type;
logger = NULL;
level = 0;
encoding = 0;
runstate = true;
workthread = NULL;
nomsg = true;
}
cpps_logging_handler::~cpps_logging_handler()
{
runstate = false;
if (workthread) {
workthread->join();//等待结束
delete workthread;
workthread = NULL;
}
for (auto msg : msgqueue)
{
delete msg;
}
msgqueue.clear();
}
void cpps_logging_handler::push(cpps_logger_message& msg)
{
cpps_logger_message* copymsg = new cpps_logger_message();
*copymsg = msg; //copy
msglock.lock();
msgqueue.push_back(copymsg);
nomsg = false;
msglock.unlock();
}
void cpps_logging_handler::work()
{
msglock.lock();
if (nomsg) {
msglock.unlock();
/*释放cpu.*/
std::this_thread::sleep_for(std::chrono::milliseconds(1));
return;
}
std::vector<cpps_logger_message*> tmplist;
tmplist = msgqueue;
msgqueue.clear();
nomsg = true;
msglock.unlock();
for (auto msg : tmplist)
{
std::string msgstr;
for (auto n : formatter)
{
if (n.type == 0)
msgstr += n.s;
else
msgstr += make_format(n.type, msg);
}
pop(msg->level,msgstr);
delete msg;
}
}
usint8 cpps_logging_handler::make_format_id(std::string kn)
{
usint8 ret = 11;
if (kn == "asctime")
ret = 1;
else if (kn == "created")
ret = 2;
else if (kn == "levelname")
ret = 3;
else if (kn == "levelno")
ret = 4;
else if (kn == "name")
ret = 5;
else if (kn == "message")
ret = 6;
else if (kn == "pathname")
ret = 7;
else if (kn == "filename")
ret = 8;
else if (kn == "lineno")
ret = 9;
else if (kn == "funcName")
ret = 10;
else if (kn == "tid")
ret = 11;
return ret;
}
std::string cpps_logging_handler::make_format(usint8 k, cpps_logger_message* msg)
{
std::string ret;
switch (k)
{
case 1:/*asctime*/
{
ret = cpps_time_time2str(msg->created);
break;
}
case 2:/*created*/
{
std::stringstream s;
s << msg->created;
ret = s.str();
break;
}
case 3:/*levelname*/
{
ret = cpps_nlevel_to_slevel(msg->level);
break;
}
case 4:/*levelno*/
{
std::stringstream s;
s << msg->level;
ret = s.str();
break;
}
case 5:/*name*/
{
ret = logger->logger_name;
break;
}
case 6:/*message*/
{
ret = msg->message;
break;
}
case 7:/*pathname*/
{
ret = msg->pathname;
break;
}
case 8:/*filename*/
{
ret = cpps_io_getfilename(msg->filename);
break;
}
case 9:/*lineno*/
{
std::stringstream s;
s << msg->lineno;
ret = s.str();
break;
}
case 10:/*funcName*/
{
std::stringstream s;
s << msg->funcname;
ret = s.str();
break;
}
case 11:/*tid*/
{
std::stringstream s;
s << cpps_this_thread_get_id();
ret = s.str();
break;
}
}
return ret;
}
void cpps_logging_handler::pop(usint8 level, std::string& msg)
{
}
void cpps_logging_handler::close()
{
}
bool cpps_logging_handler::runing()
{
return runstate;
}
void cpps_logging_handler::run(cpps_logging_handler* handler)
{
while (handler->runing())
handler->work();
handler->close();
}
void cpps_logging_handler::setformatter(std::string format)
{
//分析format.
size_t off = 0;
while (off < format.size())
{
size_t pos = format.find("%(", off);
if (pos != std::string::npos)
{
std::string zeronode = format.substr(off, pos - off);
if (!zeronode.empty())
{
cpps_formatter_node node;
node.s = zeronode;
node.type = 0;
formatter.push_back(node);
}
pos += 2;
size_t pos2 = format.find(")", pos);
if (pos2 != std::string::npos)
{
std::string kn = format.substr(pos, pos2 - pos);
//std::cout << kn << std::endl;
cpps_formatter_node node;
node.type = make_format_id(kn);
formatter.push_back(node);
off = pos2 + 2;
}
else
{
cpps_formatter_node node;
node.s = format.substr(pos);
node.type = 0;
formatter.push_back(node);
break;
}
}
else
{
cpps_formatter_node node;
node.s = format.substr(off);
node.type = 0;
formatter.push_back(node);
break;
}
}
}
bool cpps_logging_handler::canpush(bool propagate, usint8 lev)
{
if (lev < level) {
return false;
}
if (!propagate && lev == level) {
return false;
}
return true;
}
void cpps_logging_handler::setlevel(usint8 lev)
{
level = lev;
}
void cpps_logging_handler::setlogger(cpps_logger* p)
{
logger = p;
workthread = new std::thread(cpps_logging_handler::run, this);//启动线程
}
}
Loading...
Report
Report success
We will send you the feedback within 2 working days through the letter!
Please fill in the reason for the report carefully. Provide as detailed a description as possible.
Please select a report type
Cancel
Send
误判申诉

此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。

如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。

取消
提交

About

CPPS是一种轻量级的嵌入式脚本语言,其语法类似于C++。它具有当前主流语言的许多特性,包括协程、面向对象、lambda、闭包、泛型变量、自定义模块支持、GC垃圾收集和跨平台。CPPS将程序解释为字节码,通过内置语法解析在虚拟机中运行
Cancel

Releases (3)

All

The Open Source Evaluation Index is derived from the OSS Compass evaluation system, which evaluates projects around the following three dimensions

1. Open source ecosystem

  • Productivity: To evaluate the ability of open-source projects to output software artifacts and open-source value.
  • Innovation: Used to evaluate the degree of diversity of open source software and its ecosystem.
  • Robustness: Used to evaluate the ability of open-source projects to resist internal and external interference and self recover in the face of changing development environments.

2. Collaboration, People, Software

  • Collaboration: represents the degree and depth of collaboration in open source development behavior.
  • Observe the influence of core personnel in open source projects, and examine the evaluations of users and developers on open source projects from a third-party perspective.
  • Software: Evaluate the value of products exported from open-source projects and their ultimate destination. It is also a concrete manifestation of "open source software", one of the oldest mainstream directions in open source evaluation.

3. Evaluation model

    Based on the dimensions of "open source ecosystem" and "collaboration, people, and software", identify quantifiable indicators directly or indirectly related to this goal, quantitatively evaluate the health and ecology of open source projects, and ultimately form an open source evaluation index.

Contributors

All

Activities

can not load any more
Edit
About
Homepage
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/cppscript/cpps.git
git@gitee.com:cppscript/cpps.git
cppscript
cpps
cpps
master
Going to Help Center

Search

Comment
Repository Report
Back to the top
Login prompt
This operation requires login to the code cloud account. Please log in before operating.
Go to login
No account. Register

AltStyle によって変換されたページ (->オリジナル) /