/**
 * @license Copyright (c) 2017-2025, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md.
 */

'use strict';

const { format, styleText } = require( 'util' );

hexo.extend.filter.register( 'after_post_render', page => {
	if ( !hexo.projectGlobals.common || !hexo.projectGlobals.common.verbose ) {
		return;
	}
	const time = process.hrtime( page.time.start );

	// Log only pages, which generates for longer than 1 second.
	if ( time[ 0 ] > 1 ) {
		console.log(
			format(
				'Page: %s was processed in: %s.%ss.',
				styleText( 'cyanBright', page.source ),
				styleText( 'yellow', time[ 0 ] ),
				styleText( 'yellow', time[ 1 ] )
			)
		);
	}
}, 1000 );
