pinggy 0.1.4 → 0.1.5

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
@@ -81,7 +81,9 @@ The CLI supports both SSH-style flags and more descriptive long flags. Below is
81
81
  Logging:
82
82
  - --loglevel <value> Logging level: ERROR, INFO, DEBUG.
83
83
  - --logfile <path> Path to log file.
84
- - -g, --printlog Also print logs to stdout.
84
+ - --v Print logs to stdout for Cli.
85
+ - --vv Enable detailed logging for the Node.js SDK and Libpinggy.
86
+ - --vvv Enable logs from Cli, SDK and Libpinggy.
85
87
 
86
88
  Config:
87
89
  - --saveconf <file> Create a configuration file based on the provided options.
@@ -145,8 +147,9 @@ You can control logs via CLI flags (which override environment variables). If lo
145
147
 
146
148
  - To log to file and stdout at INFO level:
147
149
  ```bash
148
- pinggy -p 3000 --logfile ~/.pinggy/pinggy.log --loglevel INFO --printlog
150
+ pinggy -p 3000 --logfile ~/.pinggy/pinggy.log --loglevel INFO --v
149
151
  ```
152
+ If you provide --v, --vv, or --vvv without specifying a log level, the default log level is INFO.
150
153
 
151
154
 
152
155
 
package/dist/logger.js CHANGED
@@ -12,7 +12,7 @@ var __rest = (this && this.__rest) || function (s, e) {
12
12
  import winston from "winston";
13
13
  import fs from "fs";
14
14
  import path from "path";
15
- import { pinggy } from "@pinggy/pinggy";
15
+ import { pinggy, LogLevel } from "@pinggy/pinggy";
16
16
  // Singleton logger instance
17
17
  let _logger = null;
18
18
  function getLogger() {
@@ -29,8 +29,8 @@ export function configureLogger(values, silent = false) {
29
29
  const filePath = values.logfile || process.env.PINGGY_LOG_FILE || undefined;
30
30
  const printlog = values.v || values.vvv || undefined;
31
31
  const source = (_a = values.vvv) !== null && _a !== void 0 ? _a : false;
32
- if (values.vv || values.vvv) {
33
- enableLoggingByLogLevel();
32
+ if ((values.vv || values.vvv) || levelStr) {
33
+ enableLoggingByLogLevel(levelStr);
34
34
  }
35
35
  // Ensure log directory exists if file logging is enabled
36
36
  if (filePath) {
@@ -72,6 +72,14 @@ export function configureLogger(values, silent = false) {
72
72
  log.silent = transports.length === 0 || silent === true;
73
73
  return log;
74
74
  }
75
- function enableLoggingByLogLevel() {
76
- pinggy.setDebugLogging(true);
75
+ function enableLoggingByLogLevel(loglevel) {
76
+ if (loglevel === "DEBUG" || loglevel === "debug") {
77
+ pinggy.setDebugLogging(true, LogLevel.DEBUG);
78
+ }
79
+ else if (loglevel === "ERROR" || loglevel === "error") {
80
+ pinggy.setDebugLogging(true, LogLevel.ERROR);
81
+ }
82
+ else {
83
+ pinggy.setDebugLogging(true, LogLevel.INFO);
84
+ }
77
85
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pinggy",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "description": "Create secure, shareable tunnels to your localhost and manage them from the command line. ",
@@ -15,7 +15,7 @@
15
15
  "dev": "npm link @pinggy/pinggy && npm run build && npm link"
16
16
  },
17
17
  "dependencies": {
18
- "@pinggy/pinggy": "^0.2.3",
18
+ "@pinggy/pinggy": "^0.2.4",
19
19
  "chalk": "^5.6.2",
20
20
  "clipboardy": "^5.0.0",
21
21
  "fullscreen-ink": "^0.1.0",
package/src/logger.ts CHANGED
@@ -3,9 +3,9 @@ import fs from "fs";
3
3
  import path from "path";
4
4
  import { ParsedValues } from "./utils/parseArgs.js";
5
5
  import { cliOptions } from "./cli/options.js";
6
- import { pinggy } from "@pinggy/pinggy";
6
+ import { pinggy, LogLevel } from "@pinggy/pinggy";
7
+
7
8
 
8
- export type LogLevel = "ERROR" | "INFO" | "DEBUG";
9
9
 
10
10
  // Singleton logger instance
11
11
  let _logger: winston.Logger | null = null;
@@ -25,8 +25,8 @@ export function configureLogger(values: ParsedValues<typeof cliOptions>, silent:
25
25
  const printlog = values.v as boolean || values.vvv || undefined;
26
26
  const source = values.vvv ?? false;
27
27
 
28
- if (values.vv || values.vvv) {
29
- enableLoggingByLogLevel();
28
+ if ((values.vv || values.vvv) || levelStr) {
29
+ enableLoggingByLogLevel(levelStr);
30
30
  }
31
31
 
32
32
  // Ensure log directory exists if file logging is enabled
@@ -92,6 +92,14 @@ export function configureLogger(values: ParsedValues<typeof cliOptions>, silent:
92
92
  return log;
93
93
  }
94
94
 
95
- function enableLoggingByLogLevel(): void {
96
- pinggy.setDebugLogging(true);
95
+ function enableLoggingByLogLevel(loglevel: string | undefined): void {
96
+
97
+ if (loglevel === "DEBUG" || loglevel === "debug") {
98
+ pinggy.setDebugLogging(true, LogLevel.DEBUG);
99
+ } else if (loglevel === "ERROR" || loglevel === "error") {
100
+ pinggy.setDebugLogging(true, LogLevel.ERROR);
101
+ } else {
102
+ pinggy.setDebugLogging(true, LogLevel.INFO);
103
+ }
97
104
  }
105
+