Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F2572385
file.rs
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
file.rs
View Options
use
crate
::
process
::
Process
;
use
anyhow
::
Error
;
use
colored
::
Colorize
;
use
global_placeholders
::
global
;
use
macros_rs
::{
str
,
ternary
};
use
std
::
fs
::
File
;
use
std
::
io
::
BufRead
;
use
std
::
io
::
Seek
;
use
std
::
io
::{
self
,
BufReader
,
Read
};
use
std
::
path
::
Path
;
use
std
::
thread
;
use
std
::
time
::
Duration
;
pub
fn
logs
(
lines_to_tail
:
usize
,
log_file
:
&
str
,
id
:
usize
,
log_type
:
&
str
,
item_name
:
&
str
)
{
let
file
=
File
::
open
(
log_file
).
unwrap
();
let
reader
=
BufReader
::
new
(
file
);
let
lines
:
Vec
<
String
>
=
reader
.
lines
().
collect
::
<
io
::
Result
<
_
>>
().
unwrap
();
let
color
=
ternary
!
(
log_type
==
"out"
,
"green"
,
"red"
);
println!
(
"{}"
,
format!
(
"
\n
{log_file} last {lines_to_tail} lines:"
).
bright_black
());
let
start_index
=
if
lines
.
len
()
>
lines_to_tail
{
lines
.
len
()
-
lines_to_tail
}
else
{
0
};
for
(
i
,
line
)
in
lines
.
iter
().
skip
(
start_index
).
enumerate
()
{
let
line_number
=
start_index
+
i
;
println!
(
"{} {}"
,
format!
(
"{}|{} |"
,
id
,
item_name
).
color
(
color
),
line
);
}
}
pub
struct
Exists
;
impl
Exists
{
pub
fn
folder
(
dir_name
:
String
)
->
Result
<
bool
,
Error
>
{
Ok
(
Path
::
new
(
str
!
(
dir_name
)).
is_dir
())
}
pub
fn
file
(
file_name
:
String
)
->
Result
<
bool
,
Error
>
{
Ok
(
Path
::
new
(
str
!
(
file_name
)).
exists
())
}
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Dec 16, 12:44 PM (1 h, 41 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
484914
Default Alt Text
file.rs (1 KB)
Attached To
Mode
rPMC Process Management Controller
Attached
Detach File
Event Timeline
Log In to Comment