Gathering detailed insights and metrics for acelogger
Gathering detailed insights and metrics for acelogger
npm install acelogger
Typescript
Module System
Min. Node Version
Node Version
NPM Version
76.5
Supply Chain
98.7
Quality
75.9
Maintenance
100
Vulnerability
99.6
License
TypeScript (91.76%)
JavaScript (7.91%)
HTML (0.33%)
Total Downloads
10,072
Last Day
2
Last Week
20
Last Month
38
Last Year
1,172
1 Stars
36 Commits
3 Watching
1 Branches
1 Contributors
Minified
Minified + Gzipped
Latest Version
0.17.6
Package Id
acelogger@0.17.6
Unpacked Size
357.50 kB
Size
58.90 kB
File Count
143
NPM Version
9.6.7
Node Version
18.17.1
Publised On
12 Jan 2024
Cumulative downloads
Total Downloads
Last day
0%
2
Compared to previous day
Last week
122.2%
20
Compared to previous week
Last month
-51.9%
38
Compared to previous month
Last year
-55.9%
1,172
Compared to previous year
1
Acelogger is a light and powerful logger with tracing and metrics logging. It is inspired by opentelemetry-js.
opentelemetry, opentracing and other libraries, are hard to understand and use.
too many concepts. TracerProvider, Tracer, SpanProcessor, Span, Logger, Event, Metric, MetricProvider etc.
large code size
bad design
The logging, tracing and metrics will generate events which logged by logger, event have different alert level and event type.
$ npm install --save acelogger
1import ace, { 2 ConsoleExporterWeb, 3 LogLevel, 4 CanonicalCode, 5 isMetricEvent, 6} from 'acelogger'; 7 8ace.logger.setAttributes({ 9 os: 'MacOS', 10 osVersion: '13.0', 11}); 12 13class MetricExporterWeb implements LoggerEventExporter { 14 export(evts: LoggerEvent[]) { 15 const metricEvents = evts.filter(isMetricEvent); 16 console.log(metricEvents); 17 } 18} 19 20// set event exporter, for mesage logging 21ace.setExporter(LogLevel.Debug, new ConsoleExporterWeb()); 22// set event exporter, for metric reportings 23ace.setExporter(LogLevel.Debug, new MetricExporterWeb()); 24 25// log info level message 26ace.logger.info('test info'); 27ace.logger.storeMetrics({ 28 metrics: { 29 memoryUsage: 0.1, 30 cpuUsage: 0.5, 31 }, 32}); 33ace.logger.event('button_click'); 34 35// creat a span logger 36const spanLogger = ace.logger.startSpan('first.span', { 37 parent: ace.tracer.createSpanContext(), 38}); 39 40spanLogger.setAttributes({ 41 path: '/path/to', 42}); 43 44spanLogger.info('test info'); 45spanLogger.event('button_click'); 46 47spanLogger.endSpan({ 48 status: CanonicalCode.OK, 49});
when logging in module, you can customize a scoped logger.
1import globaleAce, { 2 SimpleManager, 3 LogLevel, 4 ConsoleExporterWeb, 5} from 'acelogger'; 6const manager = new SimpleManager(); 7 8manager.logger.setAttributes({ 9 app: globaleAce.logger.getAttributes().app, 10 appVersion: globaleAce.logger.getAttributes().appVersion, 11 lib: 'my-module@0.0.1', 12}); 13 14// init logger exporter 15manager.setExporter(LogLevel.Debug, new ConsoleExporterWeb()); 16manager.setBufferSize(0); 17 18export { manager as ace };
you can customize a exporter
1import ace, { TraceFlags, SimpleManager, LogLevel, ConsoleExporterWeb, isCountEvent } from 'acelogger'; 2 3// init logger exporter 4manager.setExporter(LogLevel.Debug, { 5 export( 6 events: LoggerEvent[], 7 resultCallback: (result: ExportResult) => void 8 ): void { 9 for (const evt of events) { 10 if (evt.traceFlags === TraceFlags.SAMPLED && !isSimpled(evt)) { 11 return; 12 } 13 if (evt.metrics) { 14 logMetric(evt); 15 } else if (isCountEvent(evt)) { 16 logCount(evt) 17 } 18 logToFile(evt); 19 } 20 }; 21});
No vulnerabilities found.
No security vulnerabilities found.