miolo 0.9.29 → 0.9.31
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/dist/cli/miolo.cli.iife.bundle.js +1 -1
- package/dist/cli/miolo.cli.iife.bundle.min.js +1 -1
- package/dist/cli/miolo.cli.iife.js +1 -1
- package/dist/cli/miolo.cli.iife.min.js +1 -1
- package/dist/cli/miolo.cli.min.mjs +1 -1
- package/dist/cli/miolo.cli.mjs +1 -1
- package/dist/cli/miolo.cli.umd.bundle.js +1 -1
- package/dist/cli/miolo.cli.umd.bundle.min.js +1 -1
- package/dist/cli/miolo.cli.umd.js +1 -1
- package/dist/cli/miolo.cli.umd.min.js +1 -1
- package/dist/cli-react/miolo.cli-react.iife.bundle.js +1 -1
- package/dist/cli-react/miolo.cli-react.iife.bundle.min.js +1 -1
- package/dist/cli-react/miolo.cli-react.iife.js +1 -1
- package/dist/cli-react/miolo.cli-react.iife.min.js +1 -1
- package/dist/cli-react/miolo.cli-react.min.mjs +1 -1
- package/dist/cli-react/miolo.cli-react.mjs +1 -1
- package/dist/cli-react/miolo.cli-react.umd.bundle.js +1 -1
- package/dist/cli-react/miolo.cli-react.umd.bundle.min.js +1 -1
- package/dist/cli-react/miolo.cli-react.umd.js +1 -1
- package/dist/cli-react/miolo.cli-react.umd.min.js +1 -1
- package/dist/server/miolo.server.cjs +167 -78
- package/dist/server/miolo.server.min.mjs +2 -2
- package/dist/server/miolo.server.mjs +168 -77
- package/dist/server/miolo.server.mjs.map +1 -1
- package/dist/server/miolo.server.node.mjs +168 -79
- package/package.json +1 -1
package/dist/cli/miolo.cli.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* miolo v0.9.
|
|
2
|
+
* miolo v0.9.31
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Donato Lorenzo <donato@afialapis.com>
|
|
5
5
|
*
|
|
@@ -18,12 +18,10 @@ var path = require('node:path');
|
|
|
18
18
|
var node_url = require('node:url');
|
|
19
19
|
var calustra = require('calustra');
|
|
20
20
|
var nodemailer = require('nodemailer');
|
|
21
|
-
var fs = require('node:fs');
|
|
22
21
|
var tinguir = require('tinguir');
|
|
23
22
|
var util = require('node:util');
|
|
24
23
|
var winston = require('winston');
|
|
25
|
-
require('
|
|
26
|
-
var intre = require('intre');
|
|
24
|
+
var fs = require('node:fs');
|
|
27
25
|
var koa_body_parser = require('koa-better-body');
|
|
28
26
|
var koa_convert = require('koa-convert');
|
|
29
27
|
var koa_compress = require('koa-compress');
|
|
@@ -594,15 +592,20 @@ var base_config = {
|
|
|
594
592
|
file: {
|
|
595
593
|
enabled: true,
|
|
596
594
|
level: 'silly',
|
|
597
|
-
|
|
598
|
-
|
|
595
|
+
filename: '/var/log/afialapis/%MIOLO%.log',
|
|
596
|
+
//frequency: undefined,
|
|
597
|
+
//datePattern: 'YYYY-MM-DD',
|
|
599
598
|
zippedArchive: true,
|
|
600
|
-
|
|
601
|
-
maxFiles:
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
599
|
+
maxsize: 1024 * 1024 * 20,
|
|
600
|
+
maxFiles: 20
|
|
601
|
+
|
|
602
|
+
//maxSize: '20m',
|
|
603
|
+
///maxFiles: '10d',
|
|
604
|
+
|
|
605
|
+
//filename: '/var/log/afialapis/%MIOLO%.%DATE%.log',
|
|
606
|
+
//auditFile: '/var/log/afialapis/%MIOLO%.audit.json',
|
|
607
|
+
//createSymlink: true,
|
|
608
|
+
//symlinkName: '%MIOLO%.log'
|
|
606
609
|
},
|
|
607
610
|
mail: {
|
|
608
611
|
enabled: false,
|
|
@@ -906,6 +909,53 @@ function init_logger_to_mail(config, emailer) {
|
|
|
906
909
|
return MailerLogger;
|
|
907
910
|
}
|
|
908
911
|
|
|
912
|
+
/**
|
|
913
|
+
* https://gist.github.com/suprememoocow/5133080
|
|
914
|
+
*
|
|
915
|
+
* https://github.com/winstonjs/winston/issues/943
|
|
916
|
+
*
|
|
917
|
+
* A function for reopening a winston File logging transport post logrotation on a HUP signal.
|
|
918
|
+
* To send a HUP to your node service, use the postrotate configuration option from logrotate.
|
|
919
|
+
* `postrotate kill -HUP ‘cat /var/run/mynodeservice.pid‘`
|
|
920
|
+
*/
|
|
921
|
+
function reopenTransportOnHupSignal(fileTransport) {
|
|
922
|
+
process.on('SIGHUP', function () {
|
|
923
|
+
var fullname = path.join(fileTransport.dirname, fileTransport._getFile(false));
|
|
924
|
+
console.log("[miolo][file-logger] SIGHUP received. Check if we need to re-open log file " + fullname + "...");
|
|
925
|
+
function reopen() {
|
|
926
|
+
console.log("[miolo][file-logger] Reopening " + fullname + "...");
|
|
927
|
+
try {
|
|
928
|
+
if (fileTransport._stream) {
|
|
929
|
+
fileTransport._stream.end();
|
|
930
|
+
fileTransport._stream.destroySoon();
|
|
931
|
+
}
|
|
932
|
+
var stream = fs.createWriteStream(fullname, fileTransport.options);
|
|
933
|
+
stream.setMaxListeners(Infinity);
|
|
934
|
+
fileTransport._size = 0;
|
|
935
|
+
fileTransport._stream = stream;
|
|
936
|
+
fileTransport.once('flush', function () {
|
|
937
|
+
fileTransport.opening = false;
|
|
938
|
+
fileTransport.emit('open', fullname);
|
|
939
|
+
});
|
|
940
|
+
fileTransport.flush();
|
|
941
|
+
console.log("[miolo][file-logger] Reopened " + fullname + " successfully");
|
|
942
|
+
} catch (error) {
|
|
943
|
+
console.error("[miolo][file-logger] Error reopening " + fullname + ": " + error.toString());
|
|
944
|
+
}
|
|
945
|
+
}
|
|
946
|
+
fs.stat(fullname, function (err) {
|
|
947
|
+
if (err && err.code == 'ENOENT') {
|
|
948
|
+
return reopen();
|
|
949
|
+
}
|
|
950
|
+
});
|
|
951
|
+
});
|
|
952
|
+
}
|
|
953
|
+
|
|
954
|
+
//import fs from 'fs'
|
|
955
|
+
//import path from 'path'
|
|
956
|
+
// import 'winston-daily-rotate-file'
|
|
957
|
+
//import { intre_to_str, intre_now } from 'intre'
|
|
958
|
+
|
|
909
959
|
var combine = winston.format.combine,
|
|
910
960
|
timestamp = winston.format.timestamp;
|
|
911
961
|
winston.format._label;
|
|
@@ -964,82 +1014,121 @@ var init_logger = function init_logger(config, emailer, prefix) {
|
|
|
964
1014
|
// https://github.com/winstonjs/winston/issues/943
|
|
965
1015
|
// https://gist.github.com/suprememoocow/5133080
|
|
966
1016
|
//
|
|
1017
|
+
if ((config == null || (_config$file = config.file) == null ? void 0 : _config$file.enabled) === true) {
|
|
1018
|
+
var _config$file2, _config$file3;
|
|
1019
|
+
var fileTransport = new winston.transports.File({
|
|
1020
|
+
filename: config != null && (_config$file2 = config.file) != null && _config$file2.filename ? config.file.filename.replace('%MIOLO%', prefix) : '/var/log/afialapis/miolo.log',
|
|
1021
|
+
level: (config == null || (_config$file3 = config.file) == null ? void 0 : _config$file3.level) || (config == null ? void 0 : config.level) || 'info',
|
|
1022
|
+
humanReadableUnhandledException: true,
|
|
1023
|
+
handleExceptions: true
|
|
1024
|
+
});
|
|
1025
|
+
reopenTransportOnHupSignal(fileTransport);
|
|
1026
|
+
_log_transports.push(fileTransport);
|
|
1027
|
+
}
|
|
1028
|
+
|
|
967
1029
|
// if (config?.file?.enabled === true) {
|
|
968
|
-
// const
|
|
969
|
-
//
|
|
1030
|
+
// const datePattern = config?.file?.datePattern || 'YYYY-MM-DD'
|
|
1031
|
+
//
|
|
1032
|
+
// const fileTransport = new transports.DailyRotateFile({
|
|
970
1033
|
// level : config?.file?.level || config?.level || 'info' ,
|
|
1034
|
+
//
|
|
1035
|
+
// frequency: config?.file?.frequency,
|
|
1036
|
+
// datePattern,
|
|
1037
|
+
// zippedArchive: config?.file?.zippedArchive == true,
|
|
1038
|
+
// maxSize: config?.file?.maxSize || '20m',
|
|
1039
|
+
// maxFiles: config?.file?.maxFiles || '10d',
|
|
1040
|
+
//
|
|
1041
|
+
// filename : config?.file?.filename
|
|
1042
|
+
// ? config.file.filename.replace('%MIOLO%', prefix)
|
|
1043
|
+
// : '/var/log/afialapis/miolo.%DATE%.log',
|
|
1044
|
+
//
|
|
1045
|
+
// auditFile: config?.file?.auditFile
|
|
1046
|
+
// ? config.file.auditFile.replace('%MIOLO%', prefix)
|
|
1047
|
+
// : '/var/log/afialapis/miolo.audit.json',
|
|
1048
|
+
//
|
|
1049
|
+
// symlinkName: config?.file?.symlinkName
|
|
1050
|
+
// ? config.file.symlinkName.replace('%MIOLO%', prefix)
|
|
1051
|
+
// : 'miolo.log',
|
|
1052
|
+
//
|
|
1053
|
+
// createSymlink: config?.file?.createSymlink == true,
|
|
1054
|
+
//
|
|
1055
|
+
// watchLog: true,
|
|
1056
|
+
//
|
|
971
1057
|
// humanReadableUnhandledException: true,
|
|
972
1058
|
// handleExceptions: true
|
|
973
1059
|
// })
|
|
974
1060
|
//
|
|
975
|
-
//
|
|
1061
|
+
// const _file_log = (s) => {
|
|
1062
|
+
// const currentDate = intre_to_str(intre_now(), datePattern)
|
|
1063
|
+
// const filename = path.join(fileTransport.dirname, fileTransport.filename.replace('%DATE%', currentDate))
|
|
1064
|
+
//
|
|
1065
|
+
// const msg = myFormat({
|
|
1066
|
+
// level: 'info',
|
|
1067
|
+
// message: `[logger][file-rotate] ${s}\n`,
|
|
1068
|
+
// timestamp: intre_now()
|
|
1069
|
+
// })
|
|
1070
|
+
// try {
|
|
1071
|
+
// fs.accessSync(filename, fs.constants.F_OK)
|
|
1072
|
+
// fs.appendFileSync(filename, msg)
|
|
1073
|
+
// } catch(_) {
|
|
1074
|
+
// fs.writeFileSync(filename, msg, { encoding: 'utf-8' })
|
|
1075
|
+
// }
|
|
1076
|
+
// if (config?.console?.enabled === true) {
|
|
1077
|
+
// if (fileTransport.levels[config?.console?.level || config?.level || 'error'] >= fileTransport.levels['info']) {
|
|
1078
|
+
// console.log(msg)
|
|
1079
|
+
// }
|
|
1080
|
+
// }
|
|
1081
|
+
// }
|
|
1082
|
+
//
|
|
1083
|
+
// const _fname = (f) => magenta(f.replace(fileTransport.dirname+path.sep, ''))
|
|
1084
|
+
//
|
|
1085
|
+
//
|
|
1086
|
+
// fileTransport.on('new', function(newFilename) {
|
|
1087
|
+
// _file_log(`New log file: ${_fname(newFilename)}`)
|
|
1088
|
+
// });
|
|
1089
|
+
//
|
|
1090
|
+
// fileTransport.on('rotate', function(oldFilename, newFilename) {
|
|
1091
|
+
// _file_log(`Rotating log file: ${_fname(oldFilename)} -- ${_fname(newFilename)}`)
|
|
1092
|
+
// })
|
|
1093
|
+
//
|
|
1094
|
+
// fileTransport.on('archive', function(zipFilename) {
|
|
1095
|
+
// _file_log(`Archived log file: ${_fname(zipFilename)}`)
|
|
1096
|
+
// })
|
|
1097
|
+
//
|
|
1098
|
+
// fileTransport.on('logRemoved', function(removedFilename) {
|
|
1099
|
+
// _file_log(`Removed log file: ${_fname(removedFilename)}`)
|
|
1100
|
+
// })
|
|
1101
|
+
//
|
|
1102
|
+
// fileTransport.on('error', function(error) {
|
|
1103
|
+
// // do something fun
|
|
1104
|
+
// _file_log(red(`Error: ${error}`))
|
|
1105
|
+
// })
|
|
976
1106
|
//
|
|
977
1107
|
// _log_transports.push(fileTransport)
|
|
978
1108
|
// }
|
|
979
1109
|
|
|
980
|
-
if (
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
var msg = myFormat({
|
|
1003
|
-
level: 'info',
|
|
1004
|
-
message: "[logger][file-rotate] " + s + "\n",
|
|
1005
|
-
timestamp: intre.intre_now()
|
|
1006
|
-
});
|
|
1007
|
-
try {
|
|
1008
|
-
fs.accessSync(filename, fs.constants.F_OK);
|
|
1009
|
-
fs.appendFileSync(filename, msg);
|
|
1010
|
-
} catch (_) {
|
|
1011
|
-
fs.writeFileSync(filename, msg, {
|
|
1012
|
-
encoding: 'utf-8'
|
|
1013
|
-
});
|
|
1014
|
-
}
|
|
1015
|
-
if ((config == null || (_config$console3 = config.console) == null ? void 0 : _config$console3.enabled) === true) {
|
|
1016
|
-
var _config$console4;
|
|
1017
|
-
if (fileTransport.levels[(config == null || (_config$console4 = config.console) == null ? void 0 : _config$console4.level) || (config == null ? void 0 : config.level) || 'error'] >= fileTransport.levels['info']) {
|
|
1018
|
-
console.log(msg);
|
|
1019
|
-
}
|
|
1020
|
-
}
|
|
1021
|
-
};
|
|
1022
|
-
var _fname = function _fname(f) {
|
|
1023
|
-
return tinguir.magenta(f.replace(fileTransport.dirname + path.sep, ''));
|
|
1024
|
-
};
|
|
1025
|
-
fileTransport.on('new', function (newFilename) {
|
|
1026
|
-
_file_log("New log file: " + _fname(newFilename));
|
|
1027
|
-
});
|
|
1028
|
-
fileTransport.on('rotate', function (oldFilename, newFilename) {
|
|
1029
|
-
_file_log("Rotating log file: " + _fname(oldFilename) + " -- " + _fname(newFilename));
|
|
1030
|
-
});
|
|
1031
|
-
fileTransport.on('archive', function (zipFilename) {
|
|
1032
|
-
_file_log("Archived log file: " + _fname(zipFilename));
|
|
1033
|
-
});
|
|
1034
|
-
fileTransport.on('logRemoved', function (removedFilename) {
|
|
1035
|
-
_file_log("Removed log file: " + _fname(removedFilename));
|
|
1036
|
-
});
|
|
1037
|
-
fileTransport.on('error', function (error) {
|
|
1038
|
-
// do something fun
|
|
1039
|
-
_file_log(tinguir.red("Error: " + error));
|
|
1040
|
-
});
|
|
1041
|
-
_log_transports.push(fileTransport);
|
|
1042
|
-
}
|
|
1110
|
+
// if (config?.file?.enabled === true) {
|
|
1111
|
+
// const fileTransport = new transports.File({
|
|
1112
|
+
// level : config?.file?.level || config?.level || 'info' ,
|
|
1113
|
+
//
|
|
1114
|
+
// zippedArchive: config?.file?.zippedArchive == true,
|
|
1115
|
+
// maxsize: config?.file?.maxsize || (1024 * 1024 * 20),
|
|
1116
|
+
// maxFiles: config?.file?.maxFiles || 20,
|
|
1117
|
+
// //
|
|
1118
|
+
// filename : config?.file?.filename
|
|
1119
|
+
// ? config.file.filename.replace('%MIOLO%', prefix)
|
|
1120
|
+
// : '/var/log/afialapis/miolo.log',
|
|
1121
|
+
// //
|
|
1122
|
+
//
|
|
1123
|
+
// humanReadableUnhandledException: true,
|
|
1124
|
+
// handleExceptions: true,
|
|
1125
|
+
// lazy: false,
|
|
1126
|
+
// tailable: true,
|
|
1127
|
+
//
|
|
1128
|
+
// })
|
|
1129
|
+
//
|
|
1130
|
+
// _log_transports.push(fileTransport)
|
|
1131
|
+
// }
|
|
1043
1132
|
|
|
1044
1133
|
//
|
|
1045
1134
|
// Mail transport
|