mirror of
https://github.com/SysRay/psOff_public.git
synced 2024-11-22 22:09:39 +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",
|
||||
"minimum": 0,
|
||||
"maximum": 5
|
||||
},
|
||||
"_customVerb": {
|
||||
"type": "object",
|
||||
"description": "Custom verbosity level for each module."
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
|
@ -7,35 +7,35 @@ const maxMessageSize = 2000;
|
||||
|
||||
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) => {
|
||||
fetch(url, fetchOpts)
|
||||
.then(async (res) => {
|
||||
if (res.ok) {
|
||||
const rateRemain = res.headers.get('X-RateLimit-Remaining');
|
||||
const rateReset = res.headers.get('X-RateLimit-Reset-After');
|
||||
if (rateRemain !== null) {
|
||||
if (parseInt(rateRemain) === 1)
|
||||
await delay((rateReset ? parseInt(rateReset) : 1) * 1500); // Hold on there, cowboy
|
||||
.then(async (res) => {
|
||||
if (res.ok) {
|
||||
const rateRemain = res.headers.get('X-RateLimit-Remaining');
|
||||
const rateReset = res.headers.get('X-RateLimit-Reset-After');
|
||||
if (rateRemain !== null) {
|
||||
if (parseInt(rateRemain) === 1)
|
||||
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);
|
||||
const jdata = res.json();
|
||||
if (typeof jdata.retry_after === 'number') {
|
||||
await delay(jdata.retry_after * 1000);
|
||||
wrap(--n);
|
||||
}
|
||||
})
|
||||
.catch(async (err) => {
|
||||
if (n > 0) {
|
||||
await delay(retryDelay);
|
||||
wrap(--n);
|
||||
} else {
|
||||
reject(`Failed after ${retries} retries.`);
|
||||
}
|
||||
});
|
||||
if (n === 0) return reject(`Failed after ${retries} retries.`);
|
||||
if (res.status !== 429) return reject(res);
|
||||
const jdata = res.json();
|
||||
if (typeof jdata.retry_after === 'number') {
|
||||
await delay(jdata.retry_after * 1000);
|
||||
wrap(--n);
|
||||
}
|
||||
})
|
||||
.catch(async (err) => {
|
||||
if (n > 0) {
|
||||
await delay(retryDelay);
|
||||
wrap(--n);
|
||||
} else {
|
||||
reject(`Failed after ${retries} retries.`);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
wrap(retries);
|
||||
@ -110,20 +110,20 @@ const guessCategory = (labels) => {
|
||||
};
|
||||
|
||||
const catOpts = {
|
||||
bugfixes: {display: 'Bugfixes 🪳'},
|
||||
stubs: {display: 'Stubbed functions 🆒'},
|
||||
impls: {display: 'Implementations 🥳'},
|
||||
general: {display: 'General ✅'},
|
||||
ench: {display: 'Enhancements 🧙'},
|
||||
contrib: {display: 'Authors 🧑💻️', splitter: ', '},
|
||||
bugfixes: { display: 'Bugfixes 🪳' },
|
||||
stubs: { display: 'Stubbed functions 🆒' },
|
||||
impls: { display: 'Implementations 🥳' },
|
||||
general: { display: 'General ✅' },
|
||||
ench: { display: 'Enhancements 🧙' },
|
||||
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];
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
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 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(`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) => {
|
||||
const msg = `* PR #${pr.number}: ${pr.title}`;
|
||||
if (!handled_contribs[pr.user.login]) {
|
||||
|
@ -24,4 +24,8 @@ EXPORT SYSV_ABI int32_t sceNpWebApi2AddHttpRequestHeader() {
|
||||
EXPORT SYSV_ABI int32_t sceNpWebApi2SendRequest() {
|
||||
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) {
|
||||
LOG_USE_MODULE(libScePad);
|
||||
LOG_TRACE(L"scePadInit()");
|
||||
(void)getData();
|
||||
return Ok;
|
||||
}
|
||||
|
@ -142,6 +142,13 @@ Config::Config() {
|
||||
|
||||
for (auto& [dkey, dval]: def.items()) {
|
||||
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)) {
|
||||
cval = dval;
|
||||
@ -171,6 +178,9 @@ Config::Config() {
|
||||
bool unused = false;
|
||||
|
||||
for (auto& [ckey, cval]: obj.items()) {
|
||||
if (ckey.starts_with("_")) { // Temporary (probably) workaround to stop removing underscore objects
|
||||
continue;
|
||||
}
|
||||
json& dval = getVal(def, ckey);
|
||||
|
||||
if (dval.is_null()) {
|
||||
@ -221,8 +231,10 @@ Config::Config() {
|
||||
};
|
||||
}
|
||||
|
||||
m_logging._future = std::async(std::launch::async | std::launch::deferred, load, &m_logging,
|
||||
json({{"$schema", "./.schemas/logging.json"}, {"sink", "FileBin"}, {"verbosity", 1}}), ConfigModFlag::LOGGING);
|
||||
m_logging._future =
|
||||
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(
|
||||
std::launch::async | std::launch::deferred, load, &m_graphics,
|
||||
|
@ -34,7 +34,7 @@ std::mutex& getMutex() {
|
||||
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 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.
|
||||
*/
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
(*trace)->Register_Module(name.data(), &pModule);
|
||||
auto lvl = getCustomVerb(name);
|
||||
if (lvl != -1) (*trace)->Set_Verbosity(pModule, (eP7Trace_Level)lvl);
|
||||
return pModule;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user