@vvlad1973/simple-logger 2.1.6 → 2.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +173 -173
- package/dist/__test__/simple-logger.test.js +65 -65
- package/dist/classes/simple-logger.d.ts +125 -125
- package/dist/classes/simple-logger.js +294 -289
- package/dist/classes/simple-logger.js.map +1 -1
- package/dist/constants/constants.d.ts +9 -9
- package/dist/constants/constants.js +9 -9
- package/dist/helpers/helpers.d.ts +31 -31
- package/dist/helpers/helpers.js +80 -80
- package/dist/helpers/validators.d.ts +17 -17
- package/dist/helpers/validators.js +26 -26
- package/dist/index.d.ts +5 -5
- package/dist/index.js +5 -5
- package/dist/index.js.map +1 -1
- package/dist/simple-logger.d.ts +80 -80
- package/dist/simple-logger.js +151 -151
- package/dist/types/simple-logger.types.d.ts +33 -33
- package/dist/types/simple-logger.types.js +1 -1
- package/docs/assets/highlight.css +85 -85
- package/docs/assets/icons.js +17 -17
- package/docs/assets/main.js +60 -60
- package/docs/assets/style.css +1611 -1611
- package/docs/classes/SimpleLogger.html +37 -37
- package/docs/index.html +68 -68
- package/docs/interfaces/ExternalLogger.html +10 -10
- package/docs/interfaces/LogFn.html +1 -1
- package/docs/interfaces/LoggerOptions.html +5 -5
- package/docs/modules.html +1 -1
- package/docs/types/LoggerFactory.html +1 -1
- package/docs/types/LoggerLevel.html +1 -1
- package/docs/types/PreparedLogCall.html +1 -1
- package/docs/variables/LoggerLevels.html +1 -1
- package/package.json +7 -7
- package/src/classes/simple-logger.ts +19 -8
- package/src/index.ts +1 -1
- package/src/types/simple-logger.types.ts +1 -1
package/dist/simple-logger.js
CHANGED
|
@@ -1,152 +1,152 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A module for simple logging with various logging levels.
|
|
3
|
-
* @module SimpleLogger
|
|
4
|
-
*/
|
|
5
|
-
import { getCallerName } from 'vvlad1973-utils';
|
|
6
|
-
const loggerLevels = [
|
|
7
|
-
'trace',
|
|
8
|
-
'debug',
|
|
9
|
-
'info',
|
|
10
|
-
'warn',
|
|
11
|
-
'error',
|
|
12
|
-
'fatal',
|
|
13
|
-
'silent',
|
|
14
|
-
];
|
|
15
|
-
/**
|
|
16
|
-
* A simple logger class with various logging levels.
|
|
17
|
-
* @class
|
|
18
|
-
* @param {string} [level='info'] - Initial logging level.
|
|
19
|
-
* @param {ExternalLogger | undefined | null} [externalLogger=null] - Optional external logger to use.
|
|
20
|
-
*/
|
|
21
|
-
export class SimpleLogger {
|
|
22
|
-
#levels = loggerLevels;
|
|
23
|
-
#currentLevel = 2;
|
|
24
|
-
#logger = console;
|
|
25
|
-
isExternal = false;
|
|
26
|
-
constructor(level, externalLogger) {
|
|
27
|
-
if (externalLogger && this.isValidLogger(externalLogger)) {
|
|
28
|
-
this.setExternalLogger(externalLogger, level);
|
|
29
|
-
}
|
|
30
|
-
else {
|
|
31
|
-
this.setLevel(level ?? 'info');
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
trace = (...args) => { };
|
|
35
|
-
debug = (...args) => { };
|
|
36
|
-
info = (...args) => { };
|
|
37
|
-
warn = (...args) => { };
|
|
38
|
-
error = (...args) => { };
|
|
39
|
-
fatal = (...args) => { };
|
|
40
|
-
silent = (...args) => { };
|
|
41
|
-
/**
|
|
42
|
-
* Updates the logging methods based on the current logging level.
|
|
43
|
-
* @private
|
|
44
|
-
*/
|
|
45
|
-
updateLoggingMethods() {
|
|
46
|
-
try {
|
|
47
|
-
const noop = (...args) => { };
|
|
48
|
-
this.trace =
|
|
49
|
-
this.#currentLevel <= 0 ? this.getExternalLoggerMethod('trace') : noop;
|
|
50
|
-
this.debug =
|
|
51
|
-
this.#currentLevel <= 1 ? this.getExternalLoggerMethod('debug') : noop;
|
|
52
|
-
this.info =
|
|
53
|
-
this.#currentLevel <= 2 ? this.getExternalLoggerMethod('info') : noop;
|
|
54
|
-
this.warn =
|
|
55
|
-
this.#currentLevel <= 3 ? this.getExternalLoggerMethod('warn') : noop;
|
|
56
|
-
this.error =
|
|
57
|
-
this.#currentLevel <= 4 ? this.getExternalLoggerMethod('error') : noop;
|
|
58
|
-
this.fatal =
|
|
59
|
-
this.#currentLevel <= 5
|
|
60
|
-
? this.getExternalLoggerMethod('fatal', 'error')
|
|
61
|
-
: noop;
|
|
62
|
-
this.silent = noop;
|
|
63
|
-
}
|
|
64
|
-
catch (error) {
|
|
65
|
-
console.error(error);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Checks if the provided logger is valid.
|
|
70
|
-
* @private
|
|
71
|
-
* @param {any} logger - The logger to check.
|
|
72
|
-
* @returns {boolean} - True if the logger is valid, otherwise false.
|
|
73
|
-
*/
|
|
74
|
-
isValidLogger(logger) {
|
|
75
|
-
return loggerLevels.every((method) => {
|
|
76
|
-
return typeof logger[method] === 'function';
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Gets the external logger method for a specific level.
|
|
81
|
-
* @param {string} method - The logger method to get.
|
|
82
|
-
* @param {string} [fallbackMethod] - The fallback logger method to get.
|
|
83
|
-
* @returns {LoggerMethod} - The logger method or a no-op function.
|
|
84
|
-
* @private
|
|
85
|
-
*/
|
|
86
|
-
getExternalLoggerMethod(method, fallbackMethod) {
|
|
87
|
-
try {
|
|
88
|
-
const loggerMethod = this.#logger[method];
|
|
89
|
-
if (typeof loggerMethod === 'function') {
|
|
90
|
-
return loggerMethod.bind(this.#logger);
|
|
91
|
-
}
|
|
92
|
-
else if (typeof fallbackMethod !== 'undefined') {
|
|
93
|
-
const fallbackLoggerMethod = this.#logger[fallbackMethod];
|
|
94
|
-
if (typeof fallbackLoggerMethod === 'function') {
|
|
95
|
-
return fallbackLoggerMethod.bind(this.#logger);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
return () => { };
|
|
99
|
-
}
|
|
100
|
-
catch (error) {
|
|
101
|
-
console.error(error);
|
|
102
|
-
return () => { };
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* Sets the logging level.
|
|
107
|
-
* @param {string} level - The logging level to set.
|
|
108
|
-
*/
|
|
109
|
-
setLevel(level) {
|
|
110
|
-
const index = this.#levels.indexOf(level.toLowerCase());
|
|
111
|
-
if (index !== -1) {
|
|
112
|
-
this.#currentLevel = index;
|
|
113
|
-
if (typeof this.#logger.level === 'string') {
|
|
114
|
-
this.#logger.level = level;
|
|
115
|
-
}
|
|
116
|
-
this.updateLoggingMethods();
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
/**
|
|
120
|
-
* Sets an external logger to be used.
|
|
121
|
-
* @param {ExternalLogger | undefined | null} logger - The external logger to set.
|
|
122
|
-
*/
|
|
123
|
-
setExternalLogger(logger, level) {
|
|
124
|
-
if (logger && this.isValidLogger(logger)) {
|
|
125
|
-
this.#logger = logger;
|
|
126
|
-
this.isExternal = true;
|
|
127
|
-
}
|
|
128
|
-
else {
|
|
129
|
-
this.#logger = console;
|
|
130
|
-
this.isExternal = false;
|
|
131
|
-
}
|
|
132
|
-
this.setLevel(level ?? logger?.level ?? this.#levels[this.#currentLevel]);
|
|
133
|
-
}
|
|
134
|
-
/**
|
|
135
|
-
* Logs the start of a function.
|
|
136
|
-
* @param {string} [functionName] - Optional function name to log.
|
|
137
|
-
*/
|
|
138
|
-
logFunctionStart(functionName) {
|
|
139
|
-
const callerName = functionName || getCallerName();
|
|
140
|
-
this.trace(`Function start: ${callerName}`);
|
|
141
|
-
}
|
|
142
|
-
/**
|
|
143
|
-
* Logs the end of a function.
|
|
144
|
-
* @param {string} [functionName] - Optional function name to log.
|
|
145
|
-
*/
|
|
146
|
-
logFunctionEnd(functionName) {
|
|
147
|
-
const callerName = functionName || getCallerName();
|
|
148
|
-
this.trace(`Function end: ${callerName}`);
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
export default SimpleLogger;
|
|
1
|
+
/**
|
|
2
|
+
* A module for simple logging with various logging levels.
|
|
3
|
+
* @module SimpleLogger
|
|
4
|
+
*/
|
|
5
|
+
import { getCallerName } from 'vvlad1973-utils';
|
|
6
|
+
const loggerLevels = [
|
|
7
|
+
'trace',
|
|
8
|
+
'debug',
|
|
9
|
+
'info',
|
|
10
|
+
'warn',
|
|
11
|
+
'error',
|
|
12
|
+
'fatal',
|
|
13
|
+
'silent',
|
|
14
|
+
];
|
|
15
|
+
/**
|
|
16
|
+
* A simple logger class with various logging levels.
|
|
17
|
+
* @class
|
|
18
|
+
* @param {string} [level='info'] - Initial logging level.
|
|
19
|
+
* @param {ExternalLogger | undefined | null} [externalLogger=null] - Optional external logger to use.
|
|
20
|
+
*/
|
|
21
|
+
export class SimpleLogger {
|
|
22
|
+
#levels = loggerLevels;
|
|
23
|
+
#currentLevel = 2;
|
|
24
|
+
#logger = console;
|
|
25
|
+
isExternal = false;
|
|
26
|
+
constructor(level, externalLogger) {
|
|
27
|
+
if (externalLogger && this.isValidLogger(externalLogger)) {
|
|
28
|
+
this.setExternalLogger(externalLogger, level);
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
this.setLevel(level ?? 'info');
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
trace = (...args) => { };
|
|
35
|
+
debug = (...args) => { };
|
|
36
|
+
info = (...args) => { };
|
|
37
|
+
warn = (...args) => { };
|
|
38
|
+
error = (...args) => { };
|
|
39
|
+
fatal = (...args) => { };
|
|
40
|
+
silent = (...args) => { };
|
|
41
|
+
/**
|
|
42
|
+
* Updates the logging methods based on the current logging level.
|
|
43
|
+
* @private
|
|
44
|
+
*/
|
|
45
|
+
updateLoggingMethods() {
|
|
46
|
+
try {
|
|
47
|
+
const noop = (...args) => { };
|
|
48
|
+
this.trace =
|
|
49
|
+
this.#currentLevel <= 0 ? this.getExternalLoggerMethod('trace') : noop;
|
|
50
|
+
this.debug =
|
|
51
|
+
this.#currentLevel <= 1 ? this.getExternalLoggerMethod('debug') : noop;
|
|
52
|
+
this.info =
|
|
53
|
+
this.#currentLevel <= 2 ? this.getExternalLoggerMethod('info') : noop;
|
|
54
|
+
this.warn =
|
|
55
|
+
this.#currentLevel <= 3 ? this.getExternalLoggerMethod('warn') : noop;
|
|
56
|
+
this.error =
|
|
57
|
+
this.#currentLevel <= 4 ? this.getExternalLoggerMethod('error') : noop;
|
|
58
|
+
this.fatal =
|
|
59
|
+
this.#currentLevel <= 5
|
|
60
|
+
? this.getExternalLoggerMethod('fatal', 'error')
|
|
61
|
+
: noop;
|
|
62
|
+
this.silent = noop;
|
|
63
|
+
}
|
|
64
|
+
catch (error) {
|
|
65
|
+
console.error(error);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Checks if the provided logger is valid.
|
|
70
|
+
* @private
|
|
71
|
+
* @param {any} logger - The logger to check.
|
|
72
|
+
* @returns {boolean} - True if the logger is valid, otherwise false.
|
|
73
|
+
*/
|
|
74
|
+
isValidLogger(logger) {
|
|
75
|
+
return loggerLevels.every((method) => {
|
|
76
|
+
return typeof logger[method] === 'function';
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Gets the external logger method for a specific level.
|
|
81
|
+
* @param {string} method - The logger method to get.
|
|
82
|
+
* @param {string} [fallbackMethod] - The fallback logger method to get.
|
|
83
|
+
* @returns {LoggerMethod} - The logger method or a no-op function.
|
|
84
|
+
* @private
|
|
85
|
+
*/
|
|
86
|
+
getExternalLoggerMethod(method, fallbackMethod) {
|
|
87
|
+
try {
|
|
88
|
+
const loggerMethod = this.#logger[method];
|
|
89
|
+
if (typeof loggerMethod === 'function') {
|
|
90
|
+
return loggerMethod.bind(this.#logger);
|
|
91
|
+
}
|
|
92
|
+
else if (typeof fallbackMethod !== 'undefined') {
|
|
93
|
+
const fallbackLoggerMethod = this.#logger[fallbackMethod];
|
|
94
|
+
if (typeof fallbackLoggerMethod === 'function') {
|
|
95
|
+
return fallbackLoggerMethod.bind(this.#logger);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return () => { };
|
|
99
|
+
}
|
|
100
|
+
catch (error) {
|
|
101
|
+
console.error(error);
|
|
102
|
+
return () => { };
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Sets the logging level.
|
|
107
|
+
* @param {string} level - The logging level to set.
|
|
108
|
+
*/
|
|
109
|
+
setLevel(level) {
|
|
110
|
+
const index = this.#levels.indexOf(level.toLowerCase());
|
|
111
|
+
if (index !== -1) {
|
|
112
|
+
this.#currentLevel = index;
|
|
113
|
+
if (typeof this.#logger.level === 'string') {
|
|
114
|
+
this.#logger.level = level;
|
|
115
|
+
}
|
|
116
|
+
this.updateLoggingMethods();
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Sets an external logger to be used.
|
|
121
|
+
* @param {ExternalLogger | undefined | null} logger - The external logger to set.
|
|
122
|
+
*/
|
|
123
|
+
setExternalLogger(logger, level) {
|
|
124
|
+
if (logger && this.isValidLogger(logger)) {
|
|
125
|
+
this.#logger = logger;
|
|
126
|
+
this.isExternal = true;
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
this.#logger = console;
|
|
130
|
+
this.isExternal = false;
|
|
131
|
+
}
|
|
132
|
+
this.setLevel(level ?? logger?.level ?? this.#levels[this.#currentLevel]);
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Logs the start of a function.
|
|
136
|
+
* @param {string} [functionName] - Optional function name to log.
|
|
137
|
+
*/
|
|
138
|
+
logFunctionStart(functionName) {
|
|
139
|
+
const callerName = functionName || getCallerName();
|
|
140
|
+
this.trace(`Function start: ${callerName}`);
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Logs the end of a function.
|
|
144
|
+
* @param {string} [functionName] - Optional function name to log.
|
|
145
|
+
*/
|
|
146
|
+
logFunctionEnd(functionName) {
|
|
147
|
+
const callerName = functionName || getCallerName();
|
|
148
|
+
this.trace(`Function end: ${callerName}`);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
export default SimpleLogger;
|
|
152
152
|
//# sourceMappingURL=simple-logger.js.map
|
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
import { LoggerLevels } from '../constants/constants';
|
|
2
|
-
export type LoggerLevel = (typeof LoggerLevels)[keyof typeof LoggerLevels];
|
|
3
|
-
export interface LogFn {
|
|
4
|
-
<T extends object>(obj: T, msg?: string, ...args: unknown[]): void;
|
|
5
|
-
(obj: unknown, msg?: string, ...args: unknown[]): void;
|
|
6
|
-
(msg: string, ...args: unknown[]): void;
|
|
7
|
-
}
|
|
8
|
-
export interface ExternalLogger {
|
|
9
|
-
trace?: LogFn;
|
|
10
|
-
debug?: LogFn;
|
|
11
|
-
info?: LogFn;
|
|
12
|
-
warn?: LogFn;
|
|
13
|
-
error?: LogFn;
|
|
14
|
-
fatal?: LogFn;
|
|
15
|
-
silent?: LogFn;
|
|
16
|
-
level?: string;
|
|
17
|
-
child?(bindings: Record<string, unknown>): ExternalLogger;
|
|
18
|
-
}
|
|
19
|
-
export type LoggerFactory = (options: Record<string, unknown>) => ExternalLogger;
|
|
20
|
-
export interface LoggerOptions {
|
|
21
|
-
level?: LoggerLevel;
|
|
22
|
-
bindings?: Record<string, unknown>;
|
|
23
|
-
msgPrefix?: string;
|
|
24
|
-
transport?: unknown;
|
|
25
|
-
transports?: {
|
|
26
|
-
targets: Array<{
|
|
27
|
-
tag?: string;
|
|
28
|
-
[key: string]: unknown;
|
|
29
|
-
}>;
|
|
30
|
-
};
|
|
31
|
-
[key: string]: unknown;
|
|
32
|
-
}
|
|
33
|
-
export type PreparedLogCall = [string, ...unknown[]] | [object, string?, ...unknown[]] | null;
|
|
1
|
+
import { LoggerLevels } from '../constants/constants';
|
|
2
|
+
export type LoggerLevel = (typeof LoggerLevels)[keyof typeof LoggerLevels];
|
|
3
|
+
export interface LogFn {
|
|
4
|
+
<T extends object>(obj: T, msg?: string, ...args: unknown[]): void;
|
|
5
|
+
(obj: unknown, msg?: string, ...args: unknown[]): void;
|
|
6
|
+
(msg: string, ...args: unknown[]): void;
|
|
7
|
+
}
|
|
8
|
+
export interface ExternalLogger {
|
|
9
|
+
trace?: LogFn;
|
|
10
|
+
debug?: LogFn;
|
|
11
|
+
info?: LogFn;
|
|
12
|
+
warn?: LogFn;
|
|
13
|
+
error?: LogFn;
|
|
14
|
+
fatal?: LogFn;
|
|
15
|
+
silent?: LogFn;
|
|
16
|
+
level?: string;
|
|
17
|
+
child?(bindings: Record<string, unknown>, options?: Record<string, unknown>): ExternalLogger;
|
|
18
|
+
}
|
|
19
|
+
export type LoggerFactory = (options: Record<string, unknown>) => ExternalLogger;
|
|
20
|
+
export interface LoggerOptions {
|
|
21
|
+
level?: LoggerLevel;
|
|
22
|
+
bindings?: Record<string, unknown>;
|
|
23
|
+
msgPrefix?: string;
|
|
24
|
+
transport?: unknown;
|
|
25
|
+
transports?: {
|
|
26
|
+
targets: Array<{
|
|
27
|
+
tag?: string;
|
|
28
|
+
[key: string]: unknown;
|
|
29
|
+
}>;
|
|
30
|
+
};
|
|
31
|
+
[key: string]: unknown;
|
|
32
|
+
}
|
|
33
|
+
export type PreparedLogCall = [string, ...unknown[]] | [object, string?, ...unknown[]] | null;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
|
2
2
|
//# sourceMappingURL=simple-logger.types.js.map
|
|
@@ -1,85 +1,85 @@
|
|
|
1
|
-
:root {
|
|
2
|
-
--light-hl-0: #795E26;
|
|
3
|
-
--dark-hl-0: #DCDCAA;
|
|
4
|
-
--light-hl-1: #000000;
|
|
5
|
-
--dark-hl-1: #D4D4D4;
|
|
6
|
-
--light-hl-2: #A31515;
|
|
7
|
-
--dark-hl-2: #CE9178;
|
|
8
|
-
--light-hl-3: #AF00DB;
|
|
9
|
-
--dark-hl-3: #C586C0;
|
|
10
|
-
--light-hl-4: #001080;
|
|
11
|
-
--dark-hl-4: #9CDCFE;
|
|
12
|
-
--light-hl-5: #0000FF;
|
|
13
|
-
--dark-hl-5: #569CD6;
|
|
14
|
-
--light-hl-6: #0070C1;
|
|
15
|
-
--dark-hl-6: #4FC1FF;
|
|
16
|
-
--light-hl-7: #098658;
|
|
17
|
-
--dark-hl-7: #B5CEA8;
|
|
18
|
-
--light-hl-8: #008000;
|
|
19
|
-
--dark-hl-8: #6A9955;
|
|
20
|
-
--light-code-background: #FFFFFF;
|
|
21
|
-
--dark-code-background: #1E1E1E;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
@media (prefers-color-scheme: light) { :root {
|
|
25
|
-
--hl-0: var(--light-hl-0);
|
|
26
|
-
--hl-1: var(--light-hl-1);
|
|
27
|
-
--hl-2: var(--light-hl-2);
|
|
28
|
-
--hl-3: var(--light-hl-3);
|
|
29
|
-
--hl-4: var(--light-hl-4);
|
|
30
|
-
--hl-5: var(--light-hl-5);
|
|
31
|
-
--hl-6: var(--light-hl-6);
|
|
32
|
-
--hl-7: var(--light-hl-7);
|
|
33
|
-
--hl-8: var(--light-hl-8);
|
|
34
|
-
--code-background: var(--light-code-background);
|
|
35
|
-
} }
|
|
36
|
-
|
|
37
|
-
@media (prefers-color-scheme: dark) { :root {
|
|
38
|
-
--hl-0: var(--dark-hl-0);
|
|
39
|
-
--hl-1: var(--dark-hl-1);
|
|
40
|
-
--hl-2: var(--dark-hl-2);
|
|
41
|
-
--hl-3: var(--dark-hl-3);
|
|
42
|
-
--hl-4: var(--dark-hl-4);
|
|
43
|
-
--hl-5: var(--dark-hl-5);
|
|
44
|
-
--hl-6: var(--dark-hl-6);
|
|
45
|
-
--hl-7: var(--dark-hl-7);
|
|
46
|
-
--hl-8: var(--dark-hl-8);
|
|
47
|
-
--code-background: var(--dark-code-background);
|
|
48
|
-
} }
|
|
49
|
-
|
|
50
|
-
:root[data-theme='light'] {
|
|
51
|
-
--hl-0: var(--light-hl-0);
|
|
52
|
-
--hl-1: var(--light-hl-1);
|
|
53
|
-
--hl-2: var(--light-hl-2);
|
|
54
|
-
--hl-3: var(--light-hl-3);
|
|
55
|
-
--hl-4: var(--light-hl-4);
|
|
56
|
-
--hl-5: var(--light-hl-5);
|
|
57
|
-
--hl-6: var(--light-hl-6);
|
|
58
|
-
--hl-7: var(--light-hl-7);
|
|
59
|
-
--hl-8: var(--light-hl-8);
|
|
60
|
-
--code-background: var(--light-code-background);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
:root[data-theme='dark'] {
|
|
64
|
-
--hl-0: var(--dark-hl-0);
|
|
65
|
-
--hl-1: var(--dark-hl-1);
|
|
66
|
-
--hl-2: var(--dark-hl-2);
|
|
67
|
-
--hl-3: var(--dark-hl-3);
|
|
68
|
-
--hl-4: var(--dark-hl-4);
|
|
69
|
-
--hl-5: var(--dark-hl-5);
|
|
70
|
-
--hl-6: var(--dark-hl-6);
|
|
71
|
-
--hl-7: var(--dark-hl-7);
|
|
72
|
-
--hl-8: var(--dark-hl-8);
|
|
73
|
-
--code-background: var(--dark-code-background);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
.hl-0 { color: var(--hl-0); }
|
|
77
|
-
.hl-1 { color: var(--hl-1); }
|
|
78
|
-
.hl-2 { color: var(--hl-2); }
|
|
79
|
-
.hl-3 { color: var(--hl-3); }
|
|
80
|
-
.hl-4 { color: var(--hl-4); }
|
|
81
|
-
.hl-5 { color: var(--hl-5); }
|
|
82
|
-
.hl-6 { color: var(--hl-6); }
|
|
83
|
-
.hl-7 { color: var(--hl-7); }
|
|
84
|
-
.hl-8 { color: var(--hl-8); }
|
|
85
|
-
pre, code { background: var(--code-background); }
|
|
1
|
+
:root {
|
|
2
|
+
--light-hl-0: #795E26;
|
|
3
|
+
--dark-hl-0: #DCDCAA;
|
|
4
|
+
--light-hl-1: #000000;
|
|
5
|
+
--dark-hl-1: #D4D4D4;
|
|
6
|
+
--light-hl-2: #A31515;
|
|
7
|
+
--dark-hl-2: #CE9178;
|
|
8
|
+
--light-hl-3: #AF00DB;
|
|
9
|
+
--dark-hl-3: #C586C0;
|
|
10
|
+
--light-hl-4: #001080;
|
|
11
|
+
--dark-hl-4: #9CDCFE;
|
|
12
|
+
--light-hl-5: #0000FF;
|
|
13
|
+
--dark-hl-5: #569CD6;
|
|
14
|
+
--light-hl-6: #0070C1;
|
|
15
|
+
--dark-hl-6: #4FC1FF;
|
|
16
|
+
--light-hl-7: #098658;
|
|
17
|
+
--dark-hl-7: #B5CEA8;
|
|
18
|
+
--light-hl-8: #008000;
|
|
19
|
+
--dark-hl-8: #6A9955;
|
|
20
|
+
--light-code-background: #FFFFFF;
|
|
21
|
+
--dark-code-background: #1E1E1E;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
@media (prefers-color-scheme: light) { :root {
|
|
25
|
+
--hl-0: var(--light-hl-0);
|
|
26
|
+
--hl-1: var(--light-hl-1);
|
|
27
|
+
--hl-2: var(--light-hl-2);
|
|
28
|
+
--hl-3: var(--light-hl-3);
|
|
29
|
+
--hl-4: var(--light-hl-4);
|
|
30
|
+
--hl-5: var(--light-hl-5);
|
|
31
|
+
--hl-6: var(--light-hl-6);
|
|
32
|
+
--hl-7: var(--light-hl-7);
|
|
33
|
+
--hl-8: var(--light-hl-8);
|
|
34
|
+
--code-background: var(--light-code-background);
|
|
35
|
+
} }
|
|
36
|
+
|
|
37
|
+
@media (prefers-color-scheme: dark) { :root {
|
|
38
|
+
--hl-0: var(--dark-hl-0);
|
|
39
|
+
--hl-1: var(--dark-hl-1);
|
|
40
|
+
--hl-2: var(--dark-hl-2);
|
|
41
|
+
--hl-3: var(--dark-hl-3);
|
|
42
|
+
--hl-4: var(--dark-hl-4);
|
|
43
|
+
--hl-5: var(--dark-hl-5);
|
|
44
|
+
--hl-6: var(--dark-hl-6);
|
|
45
|
+
--hl-7: var(--dark-hl-7);
|
|
46
|
+
--hl-8: var(--dark-hl-8);
|
|
47
|
+
--code-background: var(--dark-code-background);
|
|
48
|
+
} }
|
|
49
|
+
|
|
50
|
+
:root[data-theme='light'] {
|
|
51
|
+
--hl-0: var(--light-hl-0);
|
|
52
|
+
--hl-1: var(--light-hl-1);
|
|
53
|
+
--hl-2: var(--light-hl-2);
|
|
54
|
+
--hl-3: var(--light-hl-3);
|
|
55
|
+
--hl-4: var(--light-hl-4);
|
|
56
|
+
--hl-5: var(--light-hl-5);
|
|
57
|
+
--hl-6: var(--light-hl-6);
|
|
58
|
+
--hl-7: var(--light-hl-7);
|
|
59
|
+
--hl-8: var(--light-hl-8);
|
|
60
|
+
--code-background: var(--light-code-background);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
:root[data-theme='dark'] {
|
|
64
|
+
--hl-0: var(--dark-hl-0);
|
|
65
|
+
--hl-1: var(--dark-hl-1);
|
|
66
|
+
--hl-2: var(--dark-hl-2);
|
|
67
|
+
--hl-3: var(--dark-hl-3);
|
|
68
|
+
--hl-4: var(--dark-hl-4);
|
|
69
|
+
--hl-5: var(--dark-hl-5);
|
|
70
|
+
--hl-6: var(--dark-hl-6);
|
|
71
|
+
--hl-7: var(--dark-hl-7);
|
|
72
|
+
--hl-8: var(--dark-hl-8);
|
|
73
|
+
--code-background: var(--dark-code-background);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.hl-0 { color: var(--hl-0); }
|
|
77
|
+
.hl-1 { color: var(--hl-1); }
|
|
78
|
+
.hl-2 { color: var(--hl-2); }
|
|
79
|
+
.hl-3 { color: var(--hl-3); }
|
|
80
|
+
.hl-4 { color: var(--hl-4); }
|
|
81
|
+
.hl-5 { color: var(--hl-5); }
|
|
82
|
+
.hl-6 { color: var(--hl-6); }
|
|
83
|
+
.hl-7 { color: var(--hl-7); }
|
|
84
|
+
.hl-8 { color: var(--hl-8); }
|
|
85
|
+
pre, code { background: var(--code-background); }
|