fei.wang
10 天以前 ae7b22322555448d95fd56f505bafa325c167a26
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
<!DOCTYPE html>
<html lang="en-GB">
    <head>
        <meta charset="utf-8" />
        <title>loglevel Demo</title>
        <meta
            name="description"
            content="A demo to show the features of loglevel."
        />
        <meta name="viewport" content="width=device-width, initial-scale=1" />
        <link rel="stylesheet" href="styles.css" />
        <link
            rel="stylesheet"
            href="https://fonts.googleapis.com/css2?family=Material+Symbols+Rounded:opsz,wght,FILL,GRAD@48,600,0,0"
        />
    </head>
    <main>
        <h1>loglevel Demo</h1>
        <form id="LogForm" class="code-container">
            <code>
                log.
                <select name="logLevel" aria-label="Log type" required>
                    <option value="trace">trace</option>
                    <option value="debug">debug</option>
                    <option value="info">info</option>
                    <option value="warn">warn</option>
                    <option value="error">error</option>
                </select>
                ("
                <input
                    name="debugMessage"
                    type="text"
                    placeholder="Log text"
                    aria-label="Log text"
                    required
                />
                ")
            </code>
            <button type="submit">Run</button>
            <details>
                <summary>More information...</summary>
                Choose your level of logging and enter some text to output it to the console using logLevel.
                <a href="https://github.com/pimterry/loglevel#logging-methods">Documentation for logging methods.</a>
            </details>
        </form>
        <form id="SetLevel" class="code-container">
            <code>
                log.setLevel("
                <select name="level" aria-label="Log type" required>
                    <option value="0">trace</option>
                    <option value="1">debug</option>
                    <option value="2">info</option>
                    <option value="3">warn</option>
                    <option value="4">error</option>
                    <option value="5">silent</option>
                </select>
                ",
                <select name="persist" aria-label="Log type" required>
                    <option value="true">true</option>
                    <option value="false">false</option>
                </select>
                )
            </code>
            <button type="submit">Run</button>
            <details>
                <summary>More information...</summary>
                Disable all logging below the given level.
                <a href="https://github.com/pimterry/loglevel#logsetlevellevel-persist">Documentation for setLevel().</a>
            </details>
        </form>
        <form id="SetDefaultLevel" class="code-container">
            <code>
                log.setDefaultLevel("
                <select name="level" aria-label="Log type" required>
                    <option value="0">trace</option>
                    <option value="1">debug</option>
                    <option value="2">info</option>
                    <option value="3">warn</option>
                    <option value="4">error</option>
                    <option value="5">silent</option>
                </select>
                ")
            </code>
            <button type="submit">Run</button>
            <details>
                <summary>More information...</summary>
                Select a level and run to set the default logging level.
                <a href="https://github.com/pimterry/loglevel#logsetdefaultlevellevel">Documentation for setDefaultLevel().</a>
            </details>
        </form>
        <div class="code-container">
            <code>
                log.resetLevel()
            </code>
            <button id="ResetLevelButton" type="button">Run</button>
            <details>
                <summary>More information...</summary>
                Reset the current logging level to default.
                <a href="https://github.com/pimterry/loglevel#logresetlevel">Documentation for resetLevel().</a>
            </details>
        </div>
        <div class="code-container">
            <code>
                log.enableAll()
            </code>
            <button id="EnableAllButton" type="button">Run</button>
            <details>
                <summary>More information...</summary>
                Enables all logs - equivalent of <code>setLevel('trace')</code>.
                <a href="https://github.com/pimterry/loglevel##logenableall-and-logdisableall">Documentation for enableAll().</a>
            </details>
        </div>
        <div class="code-container">
            <code>
                log.disableAll()
            </code>
            <button id="DisableAllButton" type="button">Run</button>
            <details>
                <summary>More information...</summary>
                Disables all logs - equivalent of <code>setLevel('silent')</code>.
                <a href="https://github.com/pimterry/loglevel##logenableall-and-logdisableall">Documentation for disableAll().</a>
            </details>
        </div>
        <h2>Log State</h2>
        <div id="LogState" class="code-container">
            <label>
                Current log level
                <input name="currentLevel" aria-label="Current log level" readonly>
            </label>
            <details>
                <summary>More information...</summary>
                Uses the <code>getLevel()</code> method to display the current log level.
                <a href="https://github.com/pimterry/loglevel##logenableall-and-logdisableall">Documentation for disableAll().</a>
            </details>
        </div>
    </main>
    <script src="../dist/loglevel.js"></script>
    <script src="script.js"></script>
</html>