Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for file logging errors in windows environments #40

Merged
merged 1 commit into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 20 additions & 16 deletions src/logger.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { pino } from "pino";
import pretty from "pino-pretty";
import path from "path";

let fileLogger;
Expand All @@ -11,22 +12,25 @@ let logFileDestination;
* @param logLevel the file log level
*/
function loggerInit(directory, quiet = false, logLevel = 'info') {
logFileDestination = path.join(directory, 'log_' + (new Date()).toISOString() + '.txt');
fileLogger = pino(pino.transport({
targets: [
{
target: 'pino-pretty',
options: {
destination: logFileDestination,
mkdir: true,
colorize: false,
translateTime: 'yyyy-mm-dd HH:MM:ss',
ignore: 'pid,hostname'
},
}
]
}));
fileLogger.level = logLevel;
// replaces characters that windows does not allow in filenames
logFileDestination = path.join(directory, 'log_' + new Date().toISOString().replaceAll(/[.:]/g, '-') + '.txt');
const streams = [
{
level: logLevel,
stream: pretty({
destination: logFileDestination,
mkdir: true,
colorize: false,
translateTime: 'yyyy-mm-dd HH:MM:ss',
ignore: 'pid,hostname'
})
},
]

// using pino.multistream seems to resolve some issues with file logging in windows environments that occurred when pino.transport was used instead
fileLogger = pino({
level: logLevel
}, pino.multistream(streams));
if (quiet) {
console.log = function(){};
console.info = function(){};
Expand Down
3 changes: 2 additions & 1 deletion src/pipelineResources.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,8 @@ async function checkPipeline() {
startSpinner('Checking for API...');
const notFound = 'API not found';
try {
const command = new ListGraphqlApisCommand({apiType: "GRAPHQL"});
// set maxResults to max allowed value as workaround until https://github.com/aws/amazon-neptune-for-graphql/issues/39 is addressed
const command = new ListGraphqlApisCommand({apiType: "GRAPHQL", maxResults: 25});
const response = await appSyncClient.send(command);
response.graphqlApis.forEach(element => {
if (element.name == NAME + 'API') {
Expand Down