Skip to content

Commit bfba3c8

Browse files
committed
feat:v1.0.0
1 parent 881bc39 commit bfba3c8

File tree

5 files changed

+33
-34
lines changed

5 files changed

+33
-34
lines changed

Cargo.lock

+11-10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "hyperlane-log"
3-
version = "0.29.5"
3+
version = "1.0.0"
44
edition = "2021"
55
authors = ["ltpp-universe <root@ltpp.vip>"]
66
license = "MIT"
@@ -19,6 +19,6 @@ exclude = [
1919
file-operation = "0.3.0"
2020
http-type = "2.27.1"
2121
hyperlane-time = "0.0.3"
22-
lazy_static = "1.5.0"
2322
lombok-macros = "1.7.0"
24-
recoverable-spawn = "3.3.0"
23+
once_cell = "1.20.2"
24+
recoverable-spawn = "3.3.1"

readme.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,15 @@ cargo add hyperlane-log
2929
use hyperlane_log::*;
3030
let log: Log = Log::new("./logs", 1_024_000);
3131
let log_thread: JoinHandle<()> = log_run(&log);
32-
log.log_error("error data!", |error| {
32+
log.error("error data!", |error| {
3333
let write_data: String = format!("User error func => {:?}\n", error);
3434
write_data
3535
});
36-
log.log_info("info data!", |info| {
36+
log.info("info data!", |info| {
3737
let write_data: String = format!("User info func => {:?}\n", info);
3838
write_data
3939
});
40-
log.log_debug("debug data!", |debug| {
40+
log.debug("debug data!", |debug| {
4141
let write_data: String = format!("User debug func => {:#?}\n", debug);
4242
write_data
4343
});

src/cfg.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ fn test() {
55
use std::time::Duration;
66
let log: Log = Log::new("./logs", 1_024_000);
77
let _log_thread: JoinHandle<()> = log_run(&log);
8-
log.log_error("error data => ", |error| {
8+
log.error("error data => ", |error| {
99
let write_data: String = format!("User error func => {:?}\n", error);
1010
write_data
1111
});
12-
log.log_info("info data => ", |info| {
12+
log.info("info data => ", |info| {
1313
let write_data: String = format!("User info func => {:?}\n", info);
1414
write_data
1515
});
16-
log.log_debug("debug data => ", |debug| {
16+
log.debug("debug data => ", |debug| {
1717
let write_data: String = format!("User debug func => {:#?}\n", debug);
1818
write_data
1919
});
@@ -27,15 +27,15 @@ fn test_more_log_first() {
2727
use std::time::Duration;
2828
let log: Log = Log::new("./logs", 0);
2929
let _log_thread: JoinHandle<()> = log_run(&log);
30-
log.log_error("error data => ", |error| {
30+
log.error("error data => ", |error| {
3131
let write_data: String = format!("User error func => {:?}\n", error);
3232
write_data
3333
});
34-
log.log_info("info data => ", |info| {
34+
log.info("info data => ", |info| {
3535
let write_data: String = format!("User info func => {:?}\n", info);
3636
write_data
3737
});
38-
log.log_debug("debug data => ", |debug| {
38+
log.debug("debug data => ", |debug| {
3939
let write_data: String = format!("User debug func => {:#?}\n", debug);
4040
write_data
4141
});
@@ -52,19 +52,19 @@ fn test_more_log_second() {
5252
let _log_thread: JoinHandle<()> = log_run(&log);
5353
let times: i32 = 1000;
5454
for _ in 0..times {
55-
log.log_error("error data!", |error| {
55+
log.error("error data!", |error| {
5656
let write_data: String = format!("User error func => {:?}\n", error);
5757
write_data
5858
});
5959
}
6060
for _ in 0..times {
61-
log.log_info("info data!", |info| {
61+
log.info("info data!", |info| {
6262
let write_data: String = format!("User info func => {:?}\n", info);
6363
write_data
6464
});
6565
}
6666
for _ in 0..times {
67-
log.log_debug("debug data!", |debug| {
67+
log.debug("debug data!", |debug| {
6868
let write_data: String = format!("User debug func => {:#?}\n", debug);
6969
write_data
7070
});

src/log/impl.rs

+7-9
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,12 @@ use crate::BoxLogFunc;
88
use file_operation::*;
99
use http_type::*;
1010
use hyperlane_time::*;
11-
use lazy_static::lazy_static;
11+
use once_cell::sync::Lazy;
1212
use std::sync::{Arc, RwLock};
1313

14-
lazy_static! {
15-
static ref LOG_ERROR_QUEUE: LogListArcLock = Arc::new(RwLock::new(Vec::new()));
16-
static ref LOG_INFO_QUEUE: LogListArcLock = Arc::new(RwLock::new(Vec::new()));
17-
static ref LOG_DEBUG_QUEUE: LogListArcLock = Arc::new(RwLock::new(Vec::new()));
18-
}
14+
static LOG_ERROR_QUEUE: Lazy<LogListArcLock> = Lazy::new(|| Arc::new(RwLock::new(Vec::new())));
15+
static LOG_INFO_QUEUE: Lazy<LogListArcLock> = Lazy::new(|| Arc::new(RwLock::new(Vec::new())));
16+
static LOG_DEBUG_QUEUE: Lazy<LogListArcLock> = Lazy::new(|| Arc::new(RwLock::new(Vec::new())));
1917

2018
impl Default for Log {
2119
#[inline]
@@ -128,7 +126,7 @@ impl Log {
128126
}
129127

130128
#[inline]
131-
pub fn log_error<T, L>(&self, data: T, func: L)
129+
pub fn error<T, L>(&self, data: T, func: L)
132130
where
133131
T: LogDataTrait,
134132
L: LogFuncTrait,
@@ -137,7 +135,7 @@ impl Log {
137135
}
138136

139137
#[inline]
140-
pub fn log_info<T, L>(&self, data: T, func: L)
138+
pub fn info<T, L>(&self, data: T, func: L)
141139
where
142140
T: LogDataTrait,
143141
L: LogFuncTrait,
@@ -146,7 +144,7 @@ impl Log {
146144
}
147145

148146
#[inline]
149-
pub fn log_debug<T, L>(&self, data: T, func: L)
147+
pub fn debug<T, L>(&self, data: T, func: L)
150148
where
151149
T: LogDataTrait,
152150
L: LogFuncTrait,

0 commit comments

Comments
 (0)