• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

yunnysunny / slogger / #45

03 Jun 2024 11:04AM UTC coverage: 88.325%. Remained the same
#45

push

高阳
ci: fix coverage create error

51 of 64 branches covered (79.69%)

Branch coverage included in aggregate %.

123 of 133 relevant lines covered (92.48%)

60.62 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

100.0
/src/interfaces.ts
1
import {
2
    Writable,
3
} from 'node:stream';
4

5
export enum LogLevel {
1✔
6
    TIME = 'time',
1✔
7
    TRACE = 'trace',
1✔
8
    DEBUG = 'debug',
1✔
9
    INFO = 'info',
1✔
10
    WARN = 'warn',
1✔
11
    ERROR = 'error',
1✔
12
}
13

14
interface LogLevelTimeConfig {
15
    value: 5;
16
    showName: 'TIME';
17
}
18
export interface LogLevelNormalConfig {
19
    value: number;
20
    showName: string;
21
    color: string;
22
    colorName: string;
23
}
24
type LogLevelConfig = LogLevelNormalConfig | LogLevelTimeConfig
25
/**
26
 * @see https://en.wikipedia.org/wiki/ANSI_escape_code#Colors
27
 */
28
export const LogLevelRecord: Record<LogLevel, LogLevelConfig> = {
1✔
29
    [LogLevel.TIME]: {
30
        value: 5,
31
        showName: 'TIME',
32
    },
33
    [LogLevel.TRACE]:{
34
        value: 4,
35
        showName: 'TRACE',
36
        color : '\x1b[36m',
37
        colorName : 'cyan',
38
    },
39
    [LogLevel.DEBUG]: {
40
        value: 3,
41
        showName: 'DEBUG',
42
        color : '\x1b[32m',
43
        colorName : 'green',
44
    },
45
    [LogLevel.INFO]: {
46
        value: 2,
47
        showName: 'INFO',
48
        color : '\x1b[32m',
49
        colorName : 'green',
50
    },
51
    [LogLevel.WARN]: {
52
        value: 1,
53
        showName: 'WARN',
54
        color : '\x1b[33m',
55
        colorName : 'yellow',
56
    },
57
    [LogLevel.ERROR]: {
58
        value: 0,
59
        showName: 'ERROR',
60
        color : '\x1b[31m',
61
        colorName : 'red',
62
    },
63
}
64
export type NormalLevel = LogLevel.TRACE | LogLevel.DEBUG | LogLevel.INFO | LogLevel.WARN | LogLevel.ERROR
65
type PartialRecordOfEnum<T extends string, U> = {
66
    [P in T]?: U;
67
  };
68
export type CustomSteamRecord = PartialRecordOfEnum<NormalLevel, Writable>
69
;
70
export interface SloggerOptions {
71
    /**
72
     * The level of logger, it can be `time` `trace` `debug` `warn`  `error`,the default is `time`.
73
     */
74
    level?: LogLevel;
75
    /**
76
     * Print the log to console in a fixed time,
77
     * all logs between the interval will be cached, 
78
     * and then flush to console when the internal timer trigger.
79
     * it only takes effect when you use custom console format.
80
     */
81
    flushInterval?: number;
82
    /**
83
     * The streams to storage the log
84
     */
85
    streams?: CustomSteamRecord;
86
    /**
87
     * Whether disable the time prefix.
88
     */
89
    disableTimePrefix?: boolean;
90
    /**
91
     * Whether disable the level string prefix.
92
     */
93
    disableLevelPrefix?: boolean;
94
    /**
95
     * The name of project which use slogger
96
     */
97
    projectName?: string;
98
}
99

STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc