feat: 添加日志功能
This commit is contained in:
@ -2,7 +2,7 @@ use json::{object, array, JsonValue};
|
||||
use actix_web::{HttpRequest};
|
||||
|
||||
use crate::router::{global, items, userdata, databases};
|
||||
use crate::encryption;
|
||||
use crate::{encryption, logger};
|
||||
|
||||
pub fn add_chat(id: i64, num: i64, chats: &mut JsonValue) -> bool {
|
||||
for data in chats.members() {
|
||||
@ -23,7 +23,7 @@ pub fn add_chat(id: i64, num: i64, chats: &mut JsonValue) -> bool {
|
||||
pub fn add_chat_from_chapter_id(chapter_id: i64, chats: &mut JsonValue) -> bool {
|
||||
let chapter = &databases::CHAPTERS_MASTER[chapter_id.to_string()];
|
||||
if chapter.is_empty() {
|
||||
println!("Attempted to give unknown chapter id {}", chapter_id);
|
||||
logger::info(&format!("Attempted to give unknown chapter id {}", chapter_id));
|
||||
return false;
|
||||
}
|
||||
add_chat(chapter["masterChatId"].as_i64().unwrap(), chapter["roomId"].as_i64().unwrap(), chats)
|
||||
|
@ -1,12 +1,12 @@
|
||||
use json::{JsonValue, object};
|
||||
use actix_web::{HttpRequest};
|
||||
|
||||
use crate::encryption;
|
||||
use crate::{encryption, logger};
|
||||
|
||||
pub fn error(_req: HttpRequest, body: String) -> Option<JsonValue> {
|
||||
let body = json::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
|
||||
println!("client error: {}", body["code"]);
|
||||
|
||||
logger::error(&format!("client error: {}", body["code"]));
|
||||
|
||||
Some(object!{})
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
use json::{array, object, JsonValue};
|
||||
use rand::Rng;
|
||||
use actix_web::{HttpRequest, http::header::{HeaderMap, HeaderValue}};
|
||||
use crate::encryption;
|
||||
use crate::{encryption, logger};
|
||||
|
||||
use crate::router::{userdata, global, databases};
|
||||
|
||||
@ -113,7 +113,7 @@ pub fn use_item(item: &JsonValue, multiplier: i64, user: &mut JsonValue) {
|
||||
} else if item["consumeType"] == 4 {
|
||||
use_itemm(item["value"].as_i64().unwrap(), item["amount"].as_i64().unwrap() * multiplier, user);
|
||||
} else {
|
||||
println!("Unknown consume type {}", item["consumeType"]);
|
||||
logger::error(&format!("Unknown consume type {}", item["consumeType"]));
|
||||
}
|
||||
}
|
||||
|
||||
@ -142,7 +142,7 @@ pub fn give_gift(data: &JsonValue, user: &mut JsonValue, missions: &mut JsonValu
|
||||
}
|
||||
return false;
|
||||
}
|
||||
println!("Redeeming reward not implemented for reward type {}", data["reward_type"]);
|
||||
logger::error(&format!("Redeeming reward not implemented for reward type {}", data["reward_type"]));
|
||||
false
|
||||
}
|
||||
pub fn give_gift_basic(ty_pe: i32, id: i64, amount: i64, user: &mut JsonValue, missions: &mut JsonValue, clear_missions: &mut JsonValue, chats: &mut JsonValue) -> bool {
|
||||
@ -279,7 +279,7 @@ pub fn get_rarity(id: i64) -> i32 {
|
||||
pub fn give_character(id: i64, user: &mut JsonValue, missions: &mut JsonValue, clear_missions: &mut JsonValue, chats: &mut JsonValue) -> bool {
|
||||
let character_rarity = get_rarity(id);
|
||||
if character_rarity == 0 {
|
||||
println!("Attempted to give user undefined card!! Card id: {}", id);
|
||||
logger::error(&format!("Attempted to give user undefined card!! Card id: {}", id));
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -498,7 +498,7 @@ pub fn use_item_req(req: HttpRequest, body: String) -> Option<JsonValue> {
|
||||
if item["effectType"].as_i32().unwrap() == 1 {
|
||||
lp_modification(&mut user, item["effectValue"].as_u64().unwrap() * (amount as u64), false);
|
||||
} else {
|
||||
println!("Use item not implemented for effect type {}", item["effectType"]);
|
||||
logger::error(&format!("Use item not implemented for effect type {}", item["effectType"]));
|
||||
}
|
||||
use_item(&object!{
|
||||
value: body["id"].as_i64().unwrap(),
|
||||
|
@ -1,12 +1,12 @@
|
||||
use json::{JsonValue, object};
|
||||
use actix_web::{HttpRequest, http::header::HeaderValue};
|
||||
|
||||
use crate::encryption;
|
||||
use crate::{encryption, logger};
|
||||
use crate::router::{userdata, global};
|
||||
|
||||
fn get_asset_hash(req: &HttpRequest, body: &JsonValue) -> String {
|
||||
if body["asset_version"] != global::ASSET_VERSION && body["asset_version"] != global::ASSET_VERSION_JP {
|
||||
println!("Warning! Asset version is not what was expected. (Did the app update?)");
|
||||
logger::warn("Warning! Asset version is not what was expected. (Did the app update?)");
|
||||
}
|
||||
|
||||
let blank_header = HeaderValue::from_static("");
|
||||
@ -29,7 +29,7 @@ pub fn start(req: HttpRequest, body: String) -> Option<JsonValue> {
|
||||
let body = json::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
let mut user = userdata::get_acc(&key);
|
||||
|
||||
println!("Signin from uid: {}", user["user"]["id"].clone());
|
||||
logger::info(&format!("Signin from uid: {}", user["user"]["id"].clone()));
|
||||
|
||||
user["user"]["last_login_time"] = global::timestamp().into();
|
||||
|
||||
|
@ -2,7 +2,7 @@ use json::{array, object, JsonValue};
|
||||
use actix_web::{HttpRequest};
|
||||
use sha1::{Sha1, Digest};
|
||||
|
||||
use crate::encryption;
|
||||
use crate::{encryption, logger};
|
||||
use crate::router::{userdata, global, items};
|
||||
use crate::include_file;
|
||||
|
||||
@ -329,7 +329,7 @@ async fn npps4_req(sha_id: String) -> Option<JsonValue> {
|
||||
host.pop();
|
||||
}
|
||||
let url = format!("{}/ewexport?sha1={}", host, sha_id);
|
||||
println!("Polling NPPS4 at {}", host);
|
||||
logger::debug(&format!("Polling NPPS4 at {}", host));
|
||||
|
||||
let client = reqwest::Client::new();
|
||||
let response = client.get(url);
|
||||
|
@ -8,7 +8,7 @@ use base64::{Engine as _, engine::general_purpose};
|
||||
use crate::router::global;
|
||||
use crate::router::items;
|
||||
use crate::sql::SQLite;
|
||||
use crate::include_file;
|
||||
use crate::{include_file, logger};
|
||||
|
||||
lazy_static! {
|
||||
static ref DATABASE: SQLite = SQLite::new("userdata.db", setup_tables);
|
||||
@ -625,7 +625,7 @@ pub fn purge_accounts() -> usize {
|
||||
)).unwrap();
|
||||
for uid in dead_uids.members() {
|
||||
let user_id = uid.as_i64().unwrap();
|
||||
println!("Removing dead UID: {}", user_id);
|
||||
logger::error(&format!("Removing dead UID: {}", user_id));
|
||||
crate::router::gree::delete_uuid(user_id);
|
||||
DATABASE.lock_and_exec("DELETE FROM userdata WHERE user_id=?1", params!(user_id));
|
||||
DATABASE.lock_and_exec("DELETE FROM userhome WHERE user_id=?1", params!(user_id));
|
||||
|
Reference in New Issue
Block a user