How to use screwdriver-logger - 10 common examples

To help you get started, we’ve selected a few screwdriver-logger examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github screwdriver-cd / screwdriver / plugins / webhooks / index.js View on Github external
const ignoreExtraTriggeredPipelines = pipelineTuples.filter((t) => {
        // empty event is not created when it is triggered by extra triggers (e.g. ~tag, ~release)
        if (EXTRA_TRIGGERS.test(t.startFrom) && !hasTriggeredJob(t.pipeline, t.startFrom)) {
            logger.warn(`Event not created: there are no jobs triggered by ${t.startFrom}`);

            return false;
        }

        return true;
    });
github screwdriver-cd / screwdriver / plugins / builds / steps / logs.js View on Github external
async function getMaxLines({ baseUrl, authToken }) {
    let linesInFirstPage;

    // check lines per file by looking at the first file
    try {
        linesInFirstPage = await fetchLog({
            baseUrl,
            authToken,
            sort: 'ascending',
            linesFrom: 0,
            page: 0 });
    } catch (err) {
        logger.error(err);
        throw new Error(err);
    }

    return linesInFirstPage.length > MAX_LINES_SMALL ? MAX_LINES_BIG : MAX_LINES_SMALL;
}
github screwdriver-cd / screwdriver / plugins / builds / steps / logs.js View on Github external
async function loadLines({
    baseUrl,
    linesFrom,
    authToken,
    pagesToLoad = 10,
    sort = 'ascending',
    maxLines
}) {
    const page = Math.floor(linesFrom / maxLines);
    let morePages = false;
    let lines;

    try {
        lines = await fetchLog({ baseUrl, linesFrom, authToken, page, sort });
    } catch (err) {
        logger.error(err);
        throw new Error(err);
    }

    const linesCount = lines.length;
    const pagesToLoadUpdated = pagesToLoad - 1;
    const linesFromUpdated = sort === 'descending' ?
        linesFrom - linesCount : linesCount + linesFrom;
    // If we got lines AND there are more lines to load
    const descLoadNext = sort === 'descending' && linesCount > 0 && linesFrom - linesCount > 0;
    // If we got lines AND we reached the edge of a page
    const ascLoadNext = sort === 'ascending' && linesCount > 0
        && (linesCount + linesFrom) % maxLines === 0;

    // Load from next log if there's still lines left
    if (ascLoadNext || descLoadNext) {
        if (pagesToLoadUpdated > 0) {
github screwdriver-cd / screwdriver / plugins / webhooks / index.js View on Github external
delete newAdmins[username];
            // This is needed to make admins dirty and update db
            pipeline.admins = newAdmins;

            return pipeline.update();
        }
        // Add user as admin if permissions good and does not already exist
        if (!pipeline.admins[username]) {
            newAdmins[username] = true;
            // This is needed to make admins dirty and update db
            pipeline.admins = newAdmins;

            return pipeline.update();
        }
    } catch (err) {
        logger.info(err.message);
    }

    return Promise.resolve();
}
github screwdriver-cd / screwdriver / plugins / shutdown.js View on Github external
const gracefulStop = async () => {
        try {
            logger.info('gracefully shutting down server');
            await server.root.stop({
                timeout: 5000
            });
            process.exit(0);
        } catch (err) {
            logger.error(err);
            process.exit(1);
        }
    };
github screwdriver-cd / screwdriver / plugins / webhooks / index.js View on Github external
function hasTriggeredJob(pipeline, startFrom) {
    try {
        const nextJobs = workflowParser.getNextJobs(pipeline.workflowGraph, {
            trigger: startFrom
        });

        return nextJobs.length > 0;
    } catch (err) {
        logger.error(`Error finding triggered jobs for ${pipeline.id}: ${err}`);

        return false;
    }
}
github screwdriver-cd / screwdriver / plugins / shutdown.js View on Github external
const onSigterm = async () => {
        try {
            logger.info('got SIGTERM; running triggers before shutdown');
            const res = await promiseTimeout(taskHandler(), options.terminationGracePeriod * 1000);

            if (res) {
                logger.error(res);
            }
            await gracefulStop();
        } catch (err) {
            logger.error(err);
        }
    };
github screwdriver-cd / screwdriver / lib / server.js View on Github external
                .catch(err => logger.error('Failed to start server', err));
        });
github screwdriver-cd / screwdriver / plugins / shutdown.js View on Github external
const taskHandler = async () => {
        try {
            await Promise.all(Object.keys(tasks).map(async (key) => {
                logger.info(`executing task ${key}`);
                const item = tasks[key];

                await item.task();
            }));

            return Promise.resolve();
        } catch (err) {
            logger.error(err);
            throw err;
        }
    };
github screwdriver-cd / screwdriver / plugins / webhooks / index.js View on Github external
);
        }

        const hasBuildEvents = events.filter(e => e.builds !== null);

        if (hasBuildEvents.length === 0) {
            return reply({ message: 'No jobs to start' }).code(204);
        }

        hasBuildEvents.forEach((e) => {
            request.log(['webhook', hookId, e.id], `Event ${e.id} started`);
        });

        return reply().code(201);
    } catch (err) {
        logger.error(`[${hookId}]: ${err}`);

        return reply(boom.boomify(err));
    }
}

screwdriver-logger

Provides common logger for Screwdriver components

BSD-3-Clause
Latest version published 2 years ago

Package Health Score

48 / 100
Full package analysis