Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 51 lines (33 sloc) 1.733 kB
5d2858f @pquerna first commit
authored
1 Welcome to Log Magic.
2 ====================
3
bb37fa3 @pquerna Update README.
authored
4 This project is usable. It doesn't do everything it should, yet.
5d2858f @pquerna first commit
authored
5
995758a @pquerna the goal
authored
6 The goal is to have a fast and easy to use logging subsystem that can be dynamically
7 reconfigured to provide insight into production systems.
8
7b595d5 @wirehead making README.md friendier.
wirehead authored
9 Logmagic does its magic by generating objects with generated functions that are only modified
10 when the logging system is reconfigured, thus your entire logging path is contained within
11 long-lived functions that V8 is able to JIT.
995758a @pquerna the goal
authored
12
5d2858f @pquerna first commit
authored
13 Getting Started
14 ====================
15
16 If you had a file named like, "lib/foo/bar.js", at the top of it, you would put the following:
17
4dcd05e @pquerna Edited README.md via GitHub
authored
18 var log = require('logmagic').local('mylib.foo.bar');
5d2858f @pquerna first commit
authored
19
20 Then inside bar.js, you would just use the logger like any normal logger:
d2b3fac @pquerna Try to use backticks correctly.
authored
21
4dcd05e @pquerna Edited README.md via GitHub
authored
22 log.info("Hello!")
bb37fa3 @pquerna Update README.
authored
23 log.error("By default, format strings are not used.", {SOME_VAR: "myvalue"})
24 log.errorf("Just add 'f' to any log method, and you get format strings too: ${SOME_VAR}", {SOME_VAR: "myvalue"})
5d2858f @pquerna first commit
authored
25
26 In any other part of your application, you can reconfigure the logging subsystem at runtime,
27 making it easy to change log levels for specific modules dynamically.
28
4dcd05e @pquerna Edited README.md via GitHub
authored
29 var logmagic = require('logmagic');
0bfa6df @gdusbabek Update example to include module in sync method sig.
gdusbabek authored
30 logmagic.registerSink("mysink", function(module, level, message) { console.log(message); });
aad892d @pquerna Sketch the basics of the module out.
authored
31
32 /* Send Info an higher in the root logger to stdout */
33 logmagic.route("__root__", logmagic.INFO, "stdout")
34
4dcd05e @pquerna Edited README.md via GitHub
authored
35 /* Reconfigure all children of mylib to log all debug messages to your custom sink */
36 logmagic.route("mylib.*", logmagic.DEBUG, "mysink")
d2b3fac @pquerna Try to use backticks correctly.
authored
37
aad892d @pquerna Sketch the basics of the module out.
authored
38
5d2858f @pquerna first commit
authored
39 Builtin sinks include:
40
bb37fa3 @pquerna Update README.
authored
41 * stderr
42 * Graylog2-style JSON to stderr
b0eb7c3 @pquerna update readme to be realistic.
authored
43
44 Future features:
79b7f07 Fix future feature list
Dan Di Spaltro authored
45
b0eb7c3 @pquerna update readme to be realistic.
authored
46 * Standard Out
5d2858f @pquerna first commit
authored
47 * Facebook Scribe: https://github.com/facebook/scribe
48 * File
49 * Unix Socket
50 * Syslog
Something went wrong with that request. Please try again.