Compare commits

...

4 Commits

6 changed files with 30 additions and 17 deletions

View File

@ -1,5 +1,18 @@
# Changelog
## 2025-03-26 - 2.6.10 - fix(daemon)
Adjust console log box formatting for consistent output in daemon status messages
- Updated closing box borders to align properly in configuration error, periodic updates, and UPS status logs
- Improved visual consistency in log messages
## 2025-03-26 - 2.6.9 - fix(cli)
Improve console output formatting for status banners and logging messages
- Standardize banner messages in daemon status updates
- Refine version information banner in nupst logging
- Update UPS connection and status banners in systemd
## 2025-03-26 - 2.6.8 - fix(cli)
Improve CLI formatting, refine debug option filtering, and remove unused dgram import in SNMP manager

View File

@ -1,6 +1,6 @@
{
"name": "@serve.zone/nupst",
"version": "2.6.8",
"version": "2.6.10",
"description": "Node.js UPS Shutdown Tool for SNMP-enabled UPS devices",
"main": "dist/index.js",
"bin": {

View File

@ -3,6 +3,6 @@
*/
export const commitinfo = {
name: '@serve.zone/nupst',
version: '2.6.8',
version: '2.6.10',
description: 'Node.js UPS Shutdown Tool for SNMP-enabled UPS devices'
}

View File

@ -125,7 +125,7 @@ export class NupstDaemon {
console.error('┌─ Configuration Error ─────────────────────┐');
console.error(`${message}`);
console.error('│ Please run \'nupst setup\' first to create a configuration.');
console.error('└──────────────────────────────────────────┘');
console.error('└──────────────────────────────────────────┘');
}
/**
@ -196,7 +196,7 @@ export class NupstDaemon {
console.log(`│ Battery: ${this.config.thresholds.battery}%`);
console.log(`│ Runtime: ${this.config.thresholds.runtime} minutes`);
console.log(`│ Check Interval: ${this.config.checkInterval / 1000} seconds`);
console.log('└──────────────────────────────────────────┘');
console.log('└────────────────────────────────────────────┘');
}
/**
@ -226,20 +226,20 @@ export class NupstDaemon {
// Log status changes
if (status.powerStatus !== lastStatus) {
console.log('┌──────────────────────────────────────────┐');
console.log(`Power status changed: ${lastStatus}${status.powerStatus}`);
console.log('└──────────────────────────────────────────┘');
console.log('┌─ Power Status Change ─────────────────────┐');
console.log(`Status changed: ${lastStatus}${status.powerStatus}`);
console.log('└──────────────────────────────────────────┘');
lastStatus = status.powerStatus;
lastLogTime = currentTime; // Reset log timer when status changes
}
// Log status periodically (at least every 5 minutes)
else if (shouldLogStatus) {
const timestamp = new Date().toISOString();
console.log('┌──────────────────────────────────────────┐');
console.log(`[${timestamp}] Periodic Status Update`);
console.log('┌─ Periodic Status Update ──────────────────┐');
console.log(`Timestamp: ${timestamp}`);
console.log(`│ Power Status: ${status.powerStatus}`);
console.log(`│ Battery: ${status.batteryCapacity}% | Runtime: ${status.batteryRuntime} min`);
console.log('└──────────────────────────────────────────┘');
console.log('└──────────────────────────────────────────┘');
lastLogTime = currentTime;
}
@ -267,8 +267,8 @@ export class NupstDaemon {
batteryCapacity: number,
batteryRuntime: number
}): Promise<void> {
console.log('┌─ UPS Status ───────────────────────────────┐');
console.log(`│ Battery: ${status.batteryCapacity}% | Runtime: ${status.batteryRuntime} min`);
console.log('┌─ UPS Status ─────────────────────────────┐');
console.log(`│ Battery: ${status.batteryCapacity}% | Runtime: ${status.batteryRuntime} min`);
console.log('└──────────────────────────────────────────┘');
// Check battery threshold

View File

@ -162,7 +162,7 @@ export class Nupst {
*/
public logVersionInfo(checkForUpdates: boolean = true): void {
const version = this.getVersion();
console.log('┌─ NUPST Version ────────────────────────┐');
console.log('┌─ NUPST Version ────────────────────────────┐');
console.log(`│ Current Version: ${version}`);
if (this.updateAvailable && this.latestVersion) {

View File

@ -190,20 +190,20 @@ WantedBy=multi-user.target
timeout: Math.min(config.snmp.timeout, 10000) // Use at most 10 seconds for status check
};
console.log('┌─ Connecting to UPS... ────────────────────┐');
console.log('┌─ Connecting to UPS... ────────────────────┐');
console.log(`│ Host: ${config.snmp.host}:${config.snmp.port}`);
console.log(`│ UPS Model: ${config.snmp.upsModel || 'cyberpower'}`);
console.log('└──────────────────────────────────────────┘');
console.log('└────────────────────────────────────────────┘');
const status = await snmp.getUpsStatus(snmpConfig);
console.log('┌─ UPS Status ───────────────────────────────┐');
console.log('┌─ UPS Status ─────────────────────────────┐');
console.log(`│ Power Status: ${status.powerStatus}`);
console.log(`│ Battery Capacity: ${status.batteryCapacity}%`);
console.log(`│ Runtime Remaining: ${status.batteryRuntime} minutes`);
console.log('└──────────────────────────────────────────┘');
} catch (error) {
console.error('┌─ UPS Status ───────────────────────────────┐');
console.error('┌─ UPS Status ─────────────────────────────┐');
console.error(`│ Failed to retrieve UPS status: ${error.message}`);
console.error('└──────────────────────────────────────────┘');
}