Skip to content
This repository has been archived by the owner on Jul 11, 2021. It is now read-only.

Commit

Permalink
add logging and remove escape from queries
Browse files Browse the repository at this point in the history
  • Loading branch information
Simone Mosciatti committed Dec 18, 2017
1 parent fe7e36f commit 5824666
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ libc = "0.2.21"
fnv = "1.0.5"
uuid = { version = "0.4", features = ["v4"] }
log = "0.3.8"
env_logger = "0.4.3"

[features]
default = []
Expand Down
9 changes: 9 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ extern crate uuid;

#[macro_use]
extern crate log;
extern crate env_logger;

use env_logger::{LogBuilder, LogTarget};

use std::ffi::{CString, CStr};
use std::mem;
Expand Down Expand Up @@ -681,6 +684,12 @@ pub extern "C" fn RedisModule_OnLoad(

sql::disable_global_memory_statistics();

LogBuilder::new()
.filter(None, log::LogLevelFilter::Debug)
.target(LogTarget::Stdout)
.init()
.unwrap();

let c_data_type_name = CString::new("rediSQLDB").unwrap();
let ptr_data_type_name = c_data_type_name.as_ptr();

Expand Down
4 changes: 3 additions & 1 deletion src/redis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,9 @@ fn parse_args(argv: *mut *mut ffi::RedisModuleString,
let mut args: Vec<String> = Vec::with_capacity(argc as usize);
for i in 0..argc {
let redis_str = unsafe { *argv.offset(i as isize) };
args.push(string_ptr_len(redis_str));
let mut arg = string_ptr_len(redis_str);
arg = arg.replace("\\", "");
args.push(arg);
}
Ok(args)
}
Expand Down

0 comments on commit 5824666

Please sign in to comment.