securenow 4.0.12 → 5.0.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,6 +1,6 @@
1
1
  # SecureNow
2
2
 
3
- OpenTelemetry instrumentation for Node.js and Next.js applications - send traces to SigNoz or any OTLP-compatible backend.
3
+ OpenTelemetry instrumentation for Node.js and Next.js applications - send **traces and logs** to SigNoz or any OTLP-compatible backend.
4
4
 
5
5
  **Official npm package:** [securenow](http://securenow.ai/)
6
6
 
@@ -42,6 +42,8 @@ npx securenow init
42
42
 
43
43
  ### For Node.js Applications (Express, Fastify, NestJS, etc.)
44
44
 
45
+ #### Tracing Only
46
+
45
47
  ```bash
46
48
  # 1. Install
47
49
  npm install securenow
@@ -56,6 +58,23 @@ NODE_OPTIONS="-r securenow/register" node app.js
56
58
  NODE_OPTIONS="-r securenow/register" npm start
57
59
  ```
58
60
 
61
+ #### Tracing + Logging (Recommended)
62
+
63
+ ```bash
64
+ # 1. Install
65
+ npm install securenow
66
+
67
+ # 2. Set environment variables
68
+ export SECURENOW_APPID=my-app
69
+ export SECURENOW_INSTANCE=http://your-signoz-server:4318
70
+ export SECURENOW_LOGGING_ENABLED=1
71
+
72
+ # 3. Run with preload (adds logging)
73
+ NODE_OPTIONS="-r securenow/register -r securenow/console-instrumentation" node app.js
74
+
75
+ # Now all console.log/info/warn/error automatically go to SigNoz!
76
+ ```
77
+
59
78
  ---
60
79
 
61
80
  ## 📦 Installation
@@ -82,11 +101,19 @@ SECURENOW_APPID=my-app-name
82
101
  # Default: http://46.62.173.237:4318
83
102
  SECURENOW_INSTANCE=http://your-signoz-server:4318
84
103
 
104
+ # Optional: Enable Logging
105
+ SECURENOW_LOGGING_ENABLED=1 # Enable automatic log collection
106
+
85
107
  # Optional: Additional configuration
86
108
  SECURENOW_NO_UUID=1 # Don't append UUID to service name
87
109
  OTEL_LOG_LEVEL=info # debug|info|warn|error
88
110
  SECURENOW_DISABLE_INSTRUMENTATIONS=fs,dns # Disable specific instrumentations
89
111
  OTEL_EXPORTER_OTLP_HEADERS="x-api-key=..." # Authentication headers
112
+
113
+ # Optional: Request body capture (for debugging)
114
+ SECURENOW_CAPTURE_BODY=1 # Capture request bodies in traces
115
+ SECURENOW_MAX_BODY_SIZE=10240 # Max body size in bytes
116
+ SECURENOW_SENSITIVE_FIELDS="field1,field2" # Additional fields to redact
90
117
  ```
91
118
 
92
119
  ### Legacy Environment Variables (still supported)
@@ -116,6 +143,12 @@ SecureNow automatically instruments:
116
143
  - ✅ MongoDB
117
144
  - ✅ Redis
118
145
 
146
+ ### Logging
147
+ - ✅ Automatic console logging (console.log, info, warn, error)
148
+ - ✅ Structured logging with OpenTelemetry
149
+ - ✅ Automatic trace-log correlation
150
+ - ✅ Works with all frameworks
151
+
119
152
  ### Other
120
153
  - ✅ HTTP/HTTPS requests
121
154
  - ✅ GraphQL
@@ -126,10 +159,17 @@ SecureNow automatically instruments:
126
159
 
127
160
  ## 📚 Documentation
128
161
 
162
+ ### Quick Starts
129
163
  - **[Next.js Quick Start](./docs/NEXTJS-QUICKSTART.md)** - Get started in 30 seconds
164
+ - **[Logging Quick Start](./docs/LOGGING-QUICKSTART.md)** - Add logging in 2 minutes
165
+
166
+ ### Complete Guides
130
167
  - **[Next.js Complete Guide](./docs/NEXTJS-GUIDE.md)** - Full Next.js integration guide
168
+ - **[Logging Complete Guide](./docs/LOGGING-GUIDE.md)** - Full logging setup for all frameworks
131
169
  - **[📚 Complete Documentation](./docs/INDEX.md)** - All guides and references
132
- - **[Examples](./examples/)** - Code examples for different setups
170
+
171
+ ### Examples
172
+ - **[Code Examples](./examples/)** - Ready-to-use examples for different setups
133
173
 
134
174
  ---
135
175
 
@@ -0,0 +1,136 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * Console instrumentation helper for securenow
5
+ *
6
+ * This module wraps the default console methods (log, info, warn, error, debug)
7
+ * to automatically send logs to OpenTelemetry/SigNoz.
8
+ *
9
+ * Usage:
10
+ * 1. Enable logging: SECURENOW_LOGGING_ENABLED=1
11
+ * 2. Import this file AFTER securenow is initialized
12
+ * 3. Use console.log/info/warn/error as normal
13
+ *
14
+ * Example:
15
+ * // At the top of your app.js or index.js
16
+ * require('securenow/register'); // or use NODE_OPTIONS
17
+ * require('securenow/console-instrumentation');
18
+ *
19
+ * // Now all console calls are captured
20
+ * console.log('Application started');
21
+ * console.error('An error occurred');
22
+ */
23
+
24
+ const tracing = require('./tracing');
25
+
26
+ if (!tracing.isLoggingEnabled()) {
27
+ console.warn('[securenow] Console instrumentation loaded but logging is not enabled. Set SECURENOW_LOGGING_ENABLED=1 to enable.');
28
+ }
29
+
30
+ // Get a logger instance
31
+ const logger = tracing.getLogger('console', '1.0.0');
32
+
33
+ if (!logger) {
34
+ console.warn('[securenow] Console instrumentation: No logger available. Logging will not work.');
35
+ module.exports = {};
36
+ return;
37
+ }
38
+
39
+ // Store original console methods
40
+ const originalConsole = {
41
+ log: console.log,
42
+ info: console.info,
43
+ warn: console.warn,
44
+ error: console.error,
45
+ debug: console.debug,
46
+ };
47
+
48
+ // Map severity levels (OpenTelemetry standard)
49
+ const SeverityNumber = {
50
+ DEBUG: 5,
51
+ INFO: 9,
52
+ WARN: 13,
53
+ ERROR: 17,
54
+ };
55
+
56
+ /**
57
+ * Format arguments into a log message
58
+ */
59
+ function formatMessage(args) {
60
+ return args
61
+ .map((arg) => {
62
+ if (typeof arg === 'object' && arg !== null) {
63
+ try {
64
+ return JSON.stringify(arg);
65
+ } catch (e) {
66
+ return String(arg);
67
+ }
68
+ }
69
+ return String(arg);
70
+ })
71
+ .join(' ');
72
+ }
73
+
74
+ /**
75
+ * Emit a log record
76
+ */
77
+ function emitLog(severityNumber, severityText, args) {
78
+ const message = formatMessage(args);
79
+
80
+ try {
81
+ logger.emit({
82
+ severityNumber,
83
+ severityText,
84
+ body: message,
85
+ attributes: {
86
+ 'log.source': 'console',
87
+ 'log.method': severityText.toLowerCase(),
88
+ },
89
+ });
90
+ } catch (e) {
91
+ // Silently fail to avoid breaking the application
92
+ }
93
+ }
94
+
95
+ // Override console.log
96
+ console.log = function (...args) {
97
+ emitLog(SeverityNumber.INFO, 'INFO', args);
98
+ originalConsole.log.apply(console, args);
99
+ };
100
+
101
+ // Override console.info
102
+ console.info = function (...args) {
103
+ emitLog(SeverityNumber.INFO, 'INFO', args);
104
+ originalConsole.info.apply(console, args);
105
+ };
106
+
107
+ // Override console.warn
108
+ console.warn = function (...args) {
109
+ emitLog(SeverityNumber.WARN, 'WARN', args);
110
+ originalConsole.warn.apply(console, args);
111
+ };
112
+
113
+ // Override console.error
114
+ console.error = function (...args) {
115
+ emitLog(SeverityNumber.ERROR, 'ERROR', args);
116
+ originalConsole.error.apply(console, args);
117
+ };
118
+
119
+ // Override console.debug
120
+ console.debug = function (...args) {
121
+ emitLog(SeverityNumber.DEBUG, 'DEBUG', args);
122
+ originalConsole.debug.apply(console, args);
123
+ };
124
+
125
+ console.log('[securenow] Console instrumentation installed - all console logs will be sent to SigNoz');
126
+
127
+ module.exports = {
128
+ originalConsole,
129
+ restoreConsole: () => {
130
+ console.log = originalConsole.log;
131
+ console.info = originalConsole.info;
132
+ console.warn = originalConsole.warn;
133
+ console.error = originalConsole.error;
134
+ console.debug = originalConsole.debug;
135
+ },
136
+ };
package/docs/INDEX.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # SecureNow Documentation
2
2
 
3
- Complete documentation for SecureNow - OpenTelemetry instrumentation for Node.js and Next.js.
3
+ Complete documentation for SecureNow - OpenTelemetry instrumentation for Node.js and Next.js with tracing and logging.
4
4
 
5
5
  ## 📚 Table of Contents
6
6
 
@@ -10,6 +10,17 @@ Complete documentation for SecureNow - OpenTelemetry instrumentation for Node.js
10
10
  - **[Auto Setup](AUTO-SETUP.md)** - Automated setup instructions
11
11
  - **[Auto Setup Summary](AUTO-SETUP-SUMMARY.md)** - Summary of auto-setup features
12
12
 
13
+ ### 📋 Logging
14
+
15
+ - **[Logging Quick Start](LOGGING-QUICKSTART.md)** - Add logging to your app in 2 minutes
16
+ - **[Logging Complete Guide](LOGGING-GUIDE.md)** - Full logging setup for all frameworks
17
+ - Express.js logging examples
18
+ - Next.js logging examples
19
+ - Fastify logging examples
20
+ - NestJS logging examples
21
+ - Console instrumentation
22
+ - Direct logger API usage
23
+
13
24
  ### 📦 Next.js Integration
14
25
 
15
26
  - **[Next.js Guide](NEXTJS-GUIDE.md)** - Complete Next.js integration guide
@@ -57,6 +68,11 @@ Complete documentation for SecureNow - OpenTelemetry instrumentation for Node.js
57
68
 
58
69
  ## 🎯 Quick Links by Use Case
59
70
 
71
+ ### "I want to add logging to my app"
72
+ 1. Start with [Logging Quick Start](LOGGING-QUICKSTART.md)
73
+ 2. For complete guide: [Logging Complete Guide](LOGGING-GUIDE.md)
74
+ 3. Works with Express, Next.js, Fastify, NestJS, and all Node.js frameworks
75
+
60
76
  ### "I want to add tracing to my Next.js app"
61
77
  1. Start with [Next.js Quickstart](NEXTJS-QUICKSTART.md)
62
78
  2. For automatic setup: [Auto Setup](AUTO-SETUP.md)
@@ -86,10 +102,12 @@ Complete documentation for SecureNow - OpenTelemetry instrumentation for Node.js
86
102
 
87
103
  ### Complete Guides (Read First)
88
104
  - Customer Guide
105
+ - Logging Complete Guide
89
106
  - Next.js Guide
90
107
  - Express Body Capture
91
108
 
92
109
  ### Quick References
110
+ - Logging Quick Start
93
111
  - Next.js Quickstart
94
112
  - Body Capture Quickstart
95
113
  - Easiest Setup
@@ -125,5 +143,5 @@ Complete documentation for SecureNow - OpenTelemetry instrumentation for Node.js
125
143
 
126
144
  ---
127
145
 
128
- **Last Updated:** January 11, 2026
129
- **Package Version:** 4.0.9
146
+ **Last Updated:** March 18, 2026
147
+ **Package Version:** 4.0.12