BeginFileLog.ds
Review the BeginFileLog.ds referenced script files when scheduling inventory imports.
Note: This code is provided as a sample. It isn't a supported
part of the SiteGenesis application. You can use this code to
write all logging events to a file.
/**************************************************
* Name: BeginFileLog.ds
*
* Description:
* Create new FileLogger to write all logging events to file.
* This FileLogger will replace the normal logger in the pdict for
* the length of the operation, then its contents are appended
* to the original logger (to avoid writing everything else to file).
* If the filename is specified, the logger will write to this file
* in the TEMP directory. Otherwise, the default logs are used.
*
* @input CUSTLogger : Object
* @input LogFileName : Object
* @output custLogger : Object
* @output custError : Object
*
*****************************************************/
importScript("bc_cust:library/common/libContext.ds");
importScript("bc_cust:library/utility/exception/libcustException.ds");
importScript("bc_cust:library/utility/logging/libLog.ds");
function execute(pdict: PipelineDictionary): Number {
var _context: Context = new Context("BeginFileLog.ds");
var _logger: Log = Log.getLogger(pdict);
try {
// retrieve filename
var LogFileName: String = pdict.LogFileName;
if (!empty(LogFileName) && LogFileName.length > 0) {
_logger = Log.getFileLogger(LogFileName, _logger);
_logger.debug(_context, "Now logging to file: " + LogFileName);
} else {
_logger.warn(_context, "No filename specified, using default DemandWare logs");
_logger.setLogWriter(Log.DemandWareLogWriter);
_logger.debug(_context, "Now logging to default log file");
}
pdict.custLogger = _logger;
} catch (e) {
// Call into error handler
_logger.error(_context, "Error occurred processing pipelet: " + e.message);
// wrap error into custom exception
var exception: custException = new custException(_context, "Error occured in pipelet", e);
pdict.custError = exception;
return PIPELET_ERROR;
}
return PIPELET_NEXT;
}