namespace OS { declare var $: any; export namespace application { class Logger { /** * Referent to the log container * * @private * @type {HTMLElement} * @memberof Logger */ private target: HTMLElement; /** * Creates an instance of Logger. * @param {HTMLElement} el target container * @memberof Logger */ constructor(el: HTMLElement) { this.target = el; } /** * Log level info * * @param {string|FormattedString} s * @memberof Logger */ info(s: string | FormattedString): void { this.log("info", s, true); } /** * Log level warning * * @param {string|FormattedString} s * @memberof Logger */ warn(s: string | FormattedString): void { this.log("warn", s, true); } /** * Log level error * * @param {string|FormattedString} s * @memberof Logger */ error(s: string | FormattedString): void { this.log("error", s, true); } /** * Log a string to target container * * @private * @param {string} c class name of the appended log element * @param {string|FormattedString} s log string * @param {boolean} showtime define whether the logger should insert datetime prefix * in the log string * @memberof Logger */ private log(c: string, s: string | FormattedString, showtime: boolean): void { let el = $("
") .attr("class", `sdk-log-${c}`); if (showtime) { let date = new Date(); let prefix = date.getDate() + "/" + (date.getMonth() + 1) + "/" + date.getFullYear() + " " + date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds(); el.text(`[${prefix}]: ${s.__()}`); } else { el.text(s.__()); } $(this.target).append(el); $(this.target).scrollTop($(this.target)[0].scrollHeight); } /** * Print a log message without prefix * * @param {string|FormattedString} s text to print * @memberof Logger */ print(s: string | FormattedString): void { if(s.match(/warn/i)) { this.log("warn", s, false); } else if(s.match(/error/i)) { this.log("error", s, false); } else { this.log("info", s, false); } } /** * Empty the log container * * @memberof Logger */ clear(): void { $(this.target).empty(); } } /** * * @class libantosdk * @extends {BaseApplication} */ export class libantosdk extends BaseApplication { private sdk: API.AntOSDKBuilder; private logger: Logger; private filehandle: OS.API.VFS.BaseFileHandle; private options: GenericObject