halua 0.0.5 → 1.1.0

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/README.md CHANGED
@@ -1,85 +1,15 @@
1
- # halua
2
- logger for JS/TS projects (mainly for browser, but logging handler could be replaced with your implementation). inspired by https://pkg.go.dev/log/slog
1
+ # Halua
3
2
 
4
- ### insallation
5
- ```
6
- pnpm i halua
7
- // or
8
- npm i halua
9
- // or
10
- yarn i halua
11
- ```
12
-
13
- ### calling signature
14
- works for .debug, .info, .warn, .err
15
- ```typescript
16
- import { halua } from 'halua'
17
-
18
- halua.debug('message', 'count', 2, 'some other info', true)
19
- // output:
20
- // {timestamp} {logging level} message count="2" some other info="true"
21
- // 00/00/00 00:00:00 DEBUG message count="2" some other info="true"
22
- ```
23
- the logging func accepts string as a message for the first argument, the following argumets are [key, value] to append
24
- to a total log
25
-
26
- ### creating new instances
27
- ```typescript
28
- import { halua } from 'halua'
29
-
30
- // create new instance
31
- let logger = halua.New()
32
-
33
- // create new instance with postfix, this method will inherit dateGetter and handler
34
- logger = halua.With('operation')
35
- // will log as "{date} {level} {msg} {...args} operation"
36
- ```
3
+ Package that takes control of logging, metrics and other stuff.
37
4
 
38
- ### controlling logging level
39
- ```typescript
40
- import { halua, Level } from 'halua'
5
+ Supports Text, JSON, Console handlers as output. Custom handlers can be easily created and used.
41
6
 
42
- const logger = halua.New(null, { minLevel: Level.Warn })
43
- // now logger won't output .debug and .info logs
44
- // Levels sequence: Debug, Info, Warn, Error
45
- ```
46
-
47
- ### replacing logging with custom handler
48
- The resulting log string will be sent to handler's method
49
- ```typescript
50
- import { Handler, halua } from 'halua'
51
-
52
- class CustomHandler implements Handler {
53
- debug(msg: string) {}
54
- info(msg: string) {}
55
- warn(msg: string) {}
56
- error(msg: string) {}
57
- }
58
-
59
- // handler is replaced for current and future instances
60
- halua.setHandler(CustomHandler)
61
- ```
7
+ ### documentation
62
8
 
63
- ### replacing date getter
64
- ```typescript
65
- import { halua } from 'halua'
9
+ There is a short doc [Tour of Halua](./docs/tour_of_halua.md) - it describes basic concepts
66
10
 
67
- halua.setDateGetter(() => performance.now())
68
- // will output performance stamp instead of Date (for this and future instances)
69
- ```
70
-
71
- ### using basic logging
72
- ```typescript
73
- import { halua } from 'halua'
74
-
75
- // debug level
76
- halua.debug('debug message')
77
- // info level
78
- halua.info('info message')
11
+ ### installation
79
12
 
80
- // warning level
81
- halua.warn('warning')
82
- // error level
83
- halua.err('err message')
13
+ ```text
14
+ npm i halua
84
15
  ```
85
-