blib/lib/XS/Log.pm

filter: Statementstmt 27.0% 20 / 74 Branchbran 0.0% 0 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 33.3% 4 / 12 Podpod 12.5% 1 / 8 totaltotal 23.5% 25 / 106 CC 7 SCAR 14.9
CC
7
Cov
23%
printNote
6.0
printBug
6.0
printInf
6.0
CRAP 4.4
↑ Summary Log.xs »
1 package XS::Log;
2 #Build MD5 : IUB9AMzYdq6WFBId+Gku6A
3 #Build Time : 2025-09-24 09:47:55
4 1 our $VERSION = 1.12;
5 1 our $BUILDDATE = "2025-09-24"; #Build Time: 09:47:55
6 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 use constant {
9 #颜色设置
10 1 LOG_LEVEL_OFF => 0, # 关闭日志
11 LOG_LEVEL_FATAL => 1, # 严重错误
12 LOG_LEVEL_ERROR => 2, # 错误信息
13 LOG_LEVEL_WARN => 3, # 警告信息
14 LOG_LEVEL_INFO => 4, # 一般信息
15 LOG_LEVEL_TRACE => 5, # 最详细的日志信息
16 LOG_LEVEL_DEBUG => 6, # 调试信息
17 LOG_LEVEL_TEXT => 7, # 原文输出
18 LOG_MODE_CYCLE => 0,
19 LOG_MODE_DAILY => 1,
20 LOG_MODE_HOURLY => 2,
21 LOG_TARGET_CONSOLE => 0x01,
22 LOG_TARGET_FILE => 0x02,
23 LOG_TARGET_SYSLOG => 0x04
24 1 ▶};
Subroutine BEGIN: called CC=1 SCAR=0.0
25 1 ▶use XSLoader;
Subroutine BEGIN: called CC=1 SCAR=0.0
26 1 require Exporter;
27 1 our @ISA = qw(Exporter);
28  
29 1 our @EXPORT_OK = qw(
30 openLog closeLog flushLog setLogOptions setLogColor setLogMode setLogTargets setLogLevel
31 printNote printBug printInf printWarn printErr printFail printLog printRep
32 LOG_LEVEL_OFF LOG_LEVEL_FATAL LOG_LEVEL_ERROR LOG_LEVEL_WARN LOG_LEVEL_INFO LOG_LEVEL_TRACE LOG_LEVEL_DEBUG LOG_LEVEL_TEXT
33 LOG_MODE_CYCLE LOG_MODE_DAILY LOG_MODE_HOURLY
34 LOG_TARGET_CONSOLE LOG_TARGET_FILE LOG_TARGET_SYSLOG
35 );
36 # 定义导出标签 :all
37 1 our %EXPORT_TAGS = (
38 all => \@EXPORT_OK,
39 );
40 1 XSLoader::load('XS::Log', $VERSION);
41  
42 sub printNote {
43 0 ▶ my ($fmt, @args) = @_;
Subroutine printNote: not called CC=2 SCAR=17.9
Pod undocumented
44 0 my $msg = sprintf($fmt, @args);
45 0 my ($pkg,$file,$line);
46 0 $file = ""; $line = 0;
47 #判断是否调用caller会提速?
48 0 ▶ if(get_show_file_info())
Branch: 1 branch
BranchTrueFalseTotal
if (&get_show_file_info()) 0 0 0
49 {
50 0 ($pkg, $file, $line) = caller;
51 }
52 0 xs_log_write(LOG_LEVEL_TRACE,$file,$line,$msg);
53 }
54 sub printBug {
55 0 ▶ my ($fmt, @args) = @_;
Subroutine printBug: not called CC=2 SCAR=17.9
Pod undocumented
56 0 my $msg = sprintf($fmt, @args);
57 0 my ($pkg,$file,$line);
58 0 $file = ""; $line = 0;
59 #判断是否调用caller会提速?
60 0 ▶ if(get_show_file_info())
Branch: 1 branch
BranchTrueFalseTotal
if (&get_show_file_info()) 0 0 0
61 {
62 0 ($pkg, $file, $line) = caller;
63 }
64 0 xs_log_write(LOG_LEVEL_DEBUG,$file,$line,$msg);
65 }
66 sub printInf {
67 0 ▶ my ($fmt, @args) = @_;
Subroutine printInf: not called CC=2 SCAR=17.9
Pod undocumented
68 0 my $msg = sprintf($fmt, @args);
69 0 my ($pkg,$file,$line);
70 0 $file = ""; $line = 0;
71 #判断是否调用caller会提速?
72 0 ▶ if(get_show_file_info())
Branch: 1 branch
BranchTrueFalseTotal
if (&get_show_file_info()) 0 0 0
73 {
74 0 ($pkg, $file, $line) = caller;
75 }
76 0 xs_log_write(LOG_LEVEL_INFO,$file,$line,$msg);
77 }
78 sub printWarn {
79 0 ▶ my ($fmt, @args) = @_;
Subroutine printWarn: not called CC=2 SCAR=17.9
Pod undocumented
80 0 my $msg = sprintf($fmt, @args);
81 0 my ($pkg,$file,$line);
82 0 $file = ""; $line = 0;
83 #判断是否调用caller会提速?
84 0 ▶ if(get_show_file_info())
Branch: 1 branch
BranchTrueFalseTotal
if (&get_show_file_info()) 0 0 0
85 {
86 0 ($pkg, $file, $line) = caller;
87 }
88 0 xs_log_write(LOG_LEVEL_WARN,$file,$line,$msg);
89 }
90 sub printErr {
91 0 ▶ my ($fmt, @args) = @_;
Subroutine printErr: not called CC=2 SCAR=17.9
Pod undocumented
92 0 my $msg = sprintf($fmt, @args);
93 0 my ($pkg,$file,$line);
94 0 $file = ""; $line = 0;
95 #判断是否调用caller会提速?
96 0 ▶ if(get_show_file_info())
Branch: 1 branch
BranchTrueFalseTotal
if (&get_show_file_info()) 0 0 0
97 {
98 0 ($pkg, $file, $line) = caller;
99 }
100 0 xs_log_write(LOG_LEVEL_ERROR,$file,$line,$msg);
101 }
102 sub printFail {
103 0 ▶ my ($fmt, @args) = @_;
Subroutine printFail: not called CC=2 SCAR=17.9
Pod undocumented
104 0 my $msg = sprintf($fmt, @args);
105 0 my ($pkg,$file,$line);
106 0 $file = ""; $line = 0;
107 #判断是否调用caller会提速?
108 0 ▶ if(get_show_file_info())
Branch: 1 branch
BranchTrueFalseTotal
if (&get_show_file_info()) 0 0 0
109 {
110 0 ($pkg, $file, $line) = caller;
111 }
112 0 xs_log_write(LOG_LEVEL_FATAL,$file,$line,$msg);
113 }
114 sub printLog {
115 0 ▶ my ($fmt, @args) = @_;
Subroutine printLog: not called CC=1 SCAR=6.9
Pod undocumented
116 0 my $msg = sprintf($fmt, @args);
117 0 xs_log_write(LOG_LEVEL_TEXT,"",0,$msg);
118 }
119 sub printRep {
120 0 ▶ my ($fmt, @args) = @_;
Subroutine printRep: not called CC=1 SCAR=6.9
Pod documented
121 0 my $msg = sprintf($fmt, @args);
122 0 xs_rep_write($msg);
123 }
124 1 1;
125  
126 __END__
↑ Summary Log.xs »