Files
Unify/framework/server/tableLogger.js
2025-12-25 11:16:59 +01:00

109 lines
1.6 KiB
JavaScript

/*
Copyright (c) 2020, 2023, The Unified Company.
This code is part of Unify.
This program is free software; you can redistribute it and/or modify
it under the terms of the ESA Software Community License - Strong Copyleft LICENSE,
as published by the ESA.
See the ESA Software Community License - Strong Copyleft LICENSE, for more details.
https://unifyjs.org
*/
export default class tableLogger{
rows = new Array();
tableName = false;
maxChars = new Array(0,0,0,0,0,0);
padding = 4;
setTable( tableName, maxChars ) {
this.maxChars = maxChars;
this.tableName = tableName;
}
addColumn( a, b, c, d ) {
var row = new Array();
if( a ) {
row.push( a );
this.maxChars[0] = Math.max( this.maxChars[0], a.length );
if( b ) {
row.push( b );
this.maxChars[1] = Math.max( this.maxChars[1], b.length );
}
if( c ) {
row.push( c );
this.maxChars[2] = Math.max( this.maxChars[2], c.length );
}
if( d ) {
row.push( d );
this.maxChars[3] = Math.max( this.maxChars[3], d.length );
}
}
this.rows.push( row );
}
log() {
if( global.clusterID == 1 ) {
//Console.log("\n__________________________________________ \n");
console.log( "\nTable name:", this.tableName, "\n" );
for (var i = 0; i < this.rows.length; i++) {
var row = this.rows[i];
if( row[0] ) {
console.log( " ", row[0].padEnd( this.maxChars[0] + this.padding ), row[1] );
} else if( row[0] ) {
//console.log( "row[0]:", row[0] );
}
}
console.log("\n");
this.rows = new Array();
//this.maxChars = new Array(0,0,0,0,0,0);
}
}
}