mirror of
https://github.com/SysRay/psOff_public.git
synced 2024-11-23 06:19:41 +00:00
Initial commit
This commit is contained in:
parent
c4860de1fa
commit
bf95f56a1c
@ -23,6 +23,10 @@
|
|||||||
"description": "Verbosity level of logger.\nPossible values:\n0 - Trace\n1 - Debug\n2 - Warning\n3 - Error\n4 - Critical\n5 - None",
|
"description": "Verbosity level of logger.\nPossible values:\n0 - Trace\n1 - Debug\n2 - Warning\n3 - Error\n4 - Critical\n5 - None",
|
||||||
"minimum": 0,
|
"minimum": 0,
|
||||||
"maximum": 5
|
"maximum": 5
|
||||||
|
},
|
||||||
|
"_customVerb": {
|
||||||
|
"type": "object",
|
||||||
|
"description": "Custom verbosity level for each module."
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": [
|
"required": [
|
||||||
|
@ -7,35 +7,35 @@ const maxMessageSize = 2000;
|
|||||||
|
|
||||||
const delay = (ms) => new Promise((resolve) => setTimeout(() => resolve(), ms));
|
const delay = (ms) => new Promise((resolve) => setTimeout(() => resolve(), ms));
|
||||||
|
|
||||||
const fetchRetry = ({url, fetchOpts = {}, retryDelay = 5000, retries = 5}) => new Promise((resolve, reject) => {
|
const fetchRetry = ({ url, fetchOpts = {}, retryDelay = 5000, retries = 5 }) => new Promise((resolve, reject) => {
|
||||||
const wrap = (n) => {
|
const wrap = (n) => {
|
||||||
fetch(url, fetchOpts)
|
fetch(url, fetchOpts)
|
||||||
.then(async (res) => {
|
.then(async (res) => {
|
||||||
if (res.ok) {
|
if (res.ok) {
|
||||||
const rateRemain = res.headers.get('X-RateLimit-Remaining');
|
const rateRemain = res.headers.get('X-RateLimit-Remaining');
|
||||||
const rateReset = res.headers.get('X-RateLimit-Reset-After');
|
const rateReset = res.headers.get('X-RateLimit-Reset-After');
|
||||||
if (rateRemain !== null) {
|
if (rateRemain !== null) {
|
||||||
if (parseInt(rateRemain) === 1)
|
if (parseInt(rateRemain) === 1)
|
||||||
await delay((rateReset ? parseInt(rateReset) : 1) * 1500); // Hold on there, cowboy
|
await delay((rateReset ? parseInt(rateReset) : 1) * 1500); // Hold on there, cowboy
|
||||||
|
}
|
||||||
|
return resolve(res);
|
||||||
}
|
}
|
||||||
return resolve(res);
|
if (n === 0) return reject(`Failed after ${retries} retries.`);
|
||||||
}
|
if (res.status !== 429) return reject(res);
|
||||||
if (n === 0) return reject(`Failed after ${retries} retries.`);
|
const jdata = res.json();
|
||||||
if (res.status !== 429) return reject(res);
|
if (typeof jdata.retry_after === 'number') {
|
||||||
const jdata = res.json();
|
await delay(jdata.retry_after * 1000);
|
||||||
if (typeof jdata.retry_after === 'number') {
|
wrap(--n);
|
||||||
await delay(jdata.retry_after * 1000);
|
}
|
||||||
wrap(--n);
|
})
|
||||||
}
|
.catch(async (err) => {
|
||||||
})
|
if (n > 0) {
|
||||||
.catch(async (err) => {
|
await delay(retryDelay);
|
||||||
if (n > 0) {
|
wrap(--n);
|
||||||
await delay(retryDelay);
|
} else {
|
||||||
wrap(--n);
|
reject(`Failed after ${retries} retries.`);
|
||||||
} else {
|
}
|
||||||
reject(`Failed after ${retries} retries.`);
|
});
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
wrap(retries);
|
wrap(retries);
|
||||||
@ -110,20 +110,20 @@ const guessCategory = (labels) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const catOpts = {
|
const catOpts = {
|
||||||
bugfixes: {display: 'Bugfixes 🪳'},
|
bugfixes: { display: 'Bugfixes 🪳' },
|
||||||
stubs: {display: 'Stubbed functions 🆒'},
|
stubs: { display: 'Stubbed functions 🆒' },
|
||||||
impls: {display: 'Implementations 🥳'},
|
impls: { display: 'Implementations 🥳' },
|
||||||
general: {display: 'General ✅'},
|
general: { display: 'General ✅' },
|
||||||
ench: {display: 'Enhancements 🧙'},
|
ench: { display: 'Enhancements 🧙' },
|
||||||
contrib: {display: 'Authors 🧑💻️', splitter: ', '},
|
contrib: { display: 'Authors 🧑💻️', splitter: ', ' },
|
||||||
};
|
};
|
||||||
|
|
||||||
octokit.repos.listReleases({repo: r_name, owner: r_owner, per_page: 2, page: 1}).then(({data}) => {
|
octokit.repos.listReleases({ repo: r_name, owner: r_owner, per_page: 2, page: 1 }).then(({ data }) => {
|
||||||
const lastRelease = data[0], prevRelease = data[1];
|
const lastRelease = data[0], prevRelease = data[1];
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const readPRs = async (pagenum, list = null, retries = 0) => {
|
const readPRs = async (pagenum, list = null, retries = 0) => {
|
||||||
const out = list ?? {general: [], bugfixes: [], stubs: [], impls: [], ench: [], contrib: []};
|
const out = list ?? { general: [], bugfixes: [], stubs: [], impls: [], ench: [], contrib: [] };
|
||||||
const handled_contribs = {};
|
const handled_contribs = {};
|
||||||
|
|
||||||
const query = [];
|
const query = [];
|
||||||
@ -131,7 +131,7 @@ octokit.repos.listReleases({repo: r_name, owner: r_owner, per_page: 2, page: 1})
|
|||||||
query.push('is:pr is:closed base:features sort:author-date-asc');
|
query.push('is:pr is:closed base:features sort:author-date-asc');
|
||||||
query.push(`merged:${prevRelease.created_at}..${lastRelease.created_at}`);
|
query.push(`merged:${prevRelease.created_at}..${lastRelease.created_at}`);
|
||||||
|
|
||||||
return octokit.search.issuesAndPullRequests({q: query.join(' '), per_page: 100, page: pagenum}).then(({data}) => {
|
return octokit.search.issuesAndPullRequests({ q: query.join(' '), per_page: 100, page: pagenum }).then(({ data }) => {
|
||||||
data.items.forEach((pr) => {
|
data.items.forEach((pr) => {
|
||||||
const msg = `* PR #${pr.number}: ${pr.title}`;
|
const msg = `* PR #${pr.number}: ${pr.title}`;
|
||||||
if (!handled_contribs[pr.user.login]) {
|
if (!handled_contribs[pr.user.login]) {
|
||||||
|
@ -24,4 +24,8 @@ EXPORT SYSV_ABI int32_t sceNpWebApi2AddHttpRequestHeader() {
|
|||||||
EXPORT SYSV_ABI int32_t sceNpWebApi2SendRequest() {
|
EXPORT SYSV_ABI int32_t sceNpWebApi2SendRequest() {
|
||||||
return Ok;
|
return Ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EXPORT SYSV_ABI int32_t sceNpWebApi2CreateUserContext() {
|
||||||
|
return Ok;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -80,6 +80,7 @@ EXPORT const char* MODULE_NAME = "libScePad";
|
|||||||
|
|
||||||
EXPORT SYSV_ABI int scePadInit(void) {
|
EXPORT SYSV_ABI int scePadInit(void) {
|
||||||
LOG_USE_MODULE(libScePad);
|
LOG_USE_MODULE(libScePad);
|
||||||
|
LOG_TRACE(L"scePadInit()");
|
||||||
(void)getData();
|
(void)getData();
|
||||||
return Ok;
|
return Ok;
|
||||||
}
|
}
|
||||||
|
@ -142,6 +142,13 @@ Config::Config() {
|
|||||||
|
|
||||||
for (auto& [dkey, dval]: def.items()) {
|
for (auto& [dkey, dval]: def.items()) {
|
||||||
json& cval = getVal(obj, dkey);
|
json& cval = getVal(obj, dkey);
|
||||||
|
if (dkey.starts_with("_")) { // Temporary (probably) workaround to stop fixing underscore objects
|
||||||
|
if (cval.is_null()) {
|
||||||
|
missing = true;
|
||||||
|
cval = dval;
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if ((cval.is_null() && !dval.is_null()) || !isJsonTypesSimilar(cval, dval)) {
|
if ((cval.is_null() && !dval.is_null()) || !isJsonTypesSimilar(cval, dval)) {
|
||||||
cval = dval;
|
cval = dval;
|
||||||
@ -171,6 +178,9 @@ Config::Config() {
|
|||||||
bool unused = false;
|
bool unused = false;
|
||||||
|
|
||||||
for (auto& [ckey, cval]: obj.items()) {
|
for (auto& [ckey, cval]: obj.items()) {
|
||||||
|
if (ckey.starts_with("_")) { // Temporary (probably) workaround to stop removing underscore objects
|
||||||
|
continue;
|
||||||
|
}
|
||||||
json& dval = getVal(def, ckey);
|
json& dval = getVal(def, ckey);
|
||||||
|
|
||||||
if (dval.is_null()) {
|
if (dval.is_null()) {
|
||||||
@ -221,8 +231,10 @@ Config::Config() {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
m_logging._future = std::async(std::launch::async | std::launch::deferred, load, &m_logging,
|
m_logging._future =
|
||||||
json({{"$schema", "./.schemas/logging.json"}, {"sink", "FileBin"}, {"verbosity", 1}}), ConfigModFlag::LOGGING);
|
std::async(std::launch::async | std::launch::deferred, load, &m_logging,
|
||||||
|
json({{"$schema", "./.schemas/logging.json"}, {"sink", "FileBin"}, {"verbosity", 1}, {"_customVerb", json(json::value_t::object)}}),
|
||||||
|
ConfigModFlag::LOGGING);
|
||||||
|
|
||||||
m_graphics._future = std::async(
|
m_graphics._future = std::async(
|
||||||
std::launch::async | std::launch::deferred, load, &m_graphics,
|
std::launch::async | std::launch::deferred, load, &m_graphics,
|
||||||
|
@ -34,7 +34,7 @@ std::mutex& getMutex() {
|
|||||||
return mMutex;
|
return mMutex;
|
||||||
}
|
}
|
||||||
|
|
||||||
const wchar_t* getParams(std::wstring& params) {
|
const wchar_t* getParams(std::wstring_view name, std::wstring& params) {
|
||||||
auto [lock, jData] = accessConfig()->accessModule(ConfigModFlag::LOGGING);
|
auto [lock, jData] = accessConfig()->accessModule(ConfigModFlag::LOGGING);
|
||||||
|
|
||||||
auto readParam = [¶ms](json* field, json::value_t jsontype, const wchar_t* p7param) -> bool {
|
auto readParam = [¶ms](json* field, json::value_t jsontype, const wchar_t* p7param) -> bool {
|
||||||
@ -79,12 +79,29 @@ void* __registerLoggingModule(std::wstring_view name) {
|
|||||||
interested in is the trace.
|
interested in is the trace.
|
||||||
*/
|
*/
|
||||||
std::wstring params = L"/P7.Pool=1024 /P7.Files=0 /P7.Roll=5hr";
|
std::wstring params = L"/P7.Pool=1024 /P7.Files=0 /P7.Roll=5hr";
|
||||||
*getClient() = P7_Create_Client(getParams(params));
|
*getClient() = P7_Create_Client(getParams(name, params));
|
||||||
*trace = P7_Create_Trace(*getClient(), __APPNAME);
|
*trace = P7_Create_Trace(*getClient(), __APPNAME);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto getCustomVerb = [](std::wstring_view name) -> int32_t {
|
||||||
|
int32_t vlevel;
|
||||||
|
std::string sname(name.begin(), name.end());
|
||||||
|
auto [lock, jData] = accessConfig()->accessModule(ConfigModFlag::LOGGING);
|
||||||
|
|
||||||
|
auto& modver = (*jData)["_customVerb"][sname];
|
||||||
|
if (modver.is_number_integer()) {
|
||||||
|
printf("Custom verbosity set for: %ls\n", name.data());
|
||||||
|
return modver.get_to(vlevel);
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
};
|
||||||
|
|
||||||
IP7_Trace::hModule pModule;
|
IP7_Trace::hModule pModule;
|
||||||
(*trace)->Register_Module(name.data(), &pModule);
|
(*trace)->Register_Module(name.data(), &pModule);
|
||||||
|
auto lvl = getCustomVerb(name);
|
||||||
|
if (lvl != -1) (*trace)->Set_Verbosity(pModule, (eP7Trace_Level)lvl);
|
||||||
return pModule;
|
return pModule;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user