本文整理匯總了TypeScript中libs/slog.slog類的典型用法代碼示例。如果您正苦於以下問題:TypeScript slog類的具體用法?TypeScript slog怎麽用?TypeScript slog使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了slog類的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: main
/**
* main
*/
async function main()
{
if (process.env.NODE_ENV === 'development') {
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
}
// slog.setConfig( 'ws://localhost:8080', 'webServiceTemplate.log', 'ALL', 'slog', 'gols');
slog.setConfig('wss://localhost:8443', 'webServiceTemplate.log', 'ALL', 'slog', 'gols');
const logger = log4js.getLogger();
logger.level = 'debug';
slog.bind(
logger.debug.bind(logger),
logger.info .bind(logger),
logger.warn .bind(logger),
logger.error.bind(logger));
const log = slog.stepIn('app.ts', 'main');
const app = express();
const init = new Initializer();
await init.init(app);
init.twitter();
init.facebook();
init.google();
init.github();
init.session();
init.passport();
init.route();
listen(app);
console.log('ready.');
log.stepOut();
}
示例2: Promise
return new Promise(async (resolve : (data : Response.GetUser) => void, reject) =>
{
const log = slog.stepIn('UserApi', 'getUser');
try
{
const data : Response.GetUser = {status:Response.Status.OK, user:null};
let account : Account = null;
const {id} = param;
if (id)
{
if (isNaN(Number(id))) {
account = await AccountAgent.findByUserName(id as string);
} else {
account = await AccountAgent.find(Number(id));
}
}
if (account) {
data.user = Converter.accountToUserResponse(account);
}
log.stepOut();
resolve(data);
}
catch (err) {log.stepOut(); reject(err);}
});
示例3: isConfirmSignupEmailValid
export function isConfirmSignupEmailValid(param : Request.ConfirmSignupEmail, account : Account, locale : string) : ValidationResult
{
const log = slog.stepIn('SignupApi', 'isConfirmSignupEmailValid');
const response : Response.ConfirmSignupEmail = {status:Response.Status.OK, message:{}};
do
{
if (account === null)
{
// サインアップの確認畫麵でサインアップを完了させた後、再度サインアップを完了させようとした場合にここに到達する想定。
// サインアップIDで該當するアカウントがないということが必ずしもサインアップ済みを意味するわけではないが、
// 第三者が直接このAPIをコールするなど、想定以外のケースでなければありえないので、登録済みというメッセージでOK。
response.status = Response.Status.FAILED;
response.message.general = R.text(R.ALREADY_SIGNUP, locale);
break;
}
const hashPassword = Utils.getHashPassword(account.email, param.password, Config.PASSWORD_SALT);
if (account.password !== hashPassword)
{
response.status = Response.Status.FAILED;
response.message.password = R.text(R.INVALID_PASSWORD, locale);
}
}
while (false);
if (response.status !== Response.Status.OK) {
log.w(JSON.stringify(response, null, 2));
}
log.stepOut();
return {response};
}
示例4: isDuringTransition
/**
* 遷移中かどうか
*/
isDuringTransition() : boolean
{
const log = slog.stepIn('PageTransition', 'isDuringTransition');
log.d(this.currentApp.store.page.displayStatus.toString());
let result = false;
do
{
if (this.nextApp !== null || this.currentApp.store.page.displayStatus !== 'displayed')
{
result = true;
break;
}
if (this.currentApp.pageTransition)
{
result = this.currentApp.pageTransition.isDuringTransition();
break;
}
}
while (false);
log.stepOut();
return result;
}
示例5: init
/**
* 初期化
*/
static async init(): Promise<void>
{
const log = slog.stepIn('MySQL', 'init');
try
{
if (Config.hasMySQL())
{
const config : mysql.PoolConfig =
{
host: Config.DB_HOST,
user: Config.DB_USER,
password: Config.DB_PASSWORD,
database: Config.DB_NAME,
charset: 'utf8mb4',
timezone: 'utc'
};
Database.pool = mysql.createPool(config);
const conn = await Database.getConnection();
conn.release();
}
log.stepOut();
}
catch (err)
{
console.error('MySQLの初期化に失敗しました。');
console.error(err.message);
log.e(err.message);
log.stepOut();
// すぐに終了するとログが出力されないので數秒待ってから終了する
setTimeout(() => process.exit(-1), 3000);
}
}
示例6: deleteOne
deleteOne(filter : object)
{
const log = slog.stepIn('Collection', 'deleteOne');
log.d(`${this.name}:${JSON.stringify(filter, null, 2)}`);
log.stepOut();
return this.collection.deleteOne(filter);
}
示例7: update
update(filter : object, obj : object)
{
const log = slog.stepIn('Collection', 'update');
log.d(`${this.name}:${JSON.stringify(filter, null, 2)}\n${JSON.stringify(obj, null, 2)}`);
log.stepOut();
return this.collection.update(filter, obj);
}
示例8: onUnlinkProvider
export async function onUnlinkProvider(req : express.Request, res : express.Response)
{
const log = slog.stepIn('SettingsApi', 'onUnlinkProvider');
try
{
do
{
const locale = req.ext.locale;
const param : Request.UnlinkProvider = req.body;
const condition : Request.UnlinkProvider =
{
provider: ['string', null, true] as any
};
if (Utils.existsParameters(param, condition) === false)
{
res.ext.badRequest(locale);
break;
}
// プロバイダ名チェック
const {provider} = param;
log.d(`${provider}`);
if (provider !== 'twitter'
&& provider !== 'facebook'
&& provider !== 'google'
&& provider !== 'github')
{
res.ext.badRequest(locale);
break;
}
// アカウント更新
const session : Session = req.ext.session;
const account = await AccountAgent.find(session.account_id);
if (AccountAgent.canUnlink(account, provider))
{
account[provider] = null;
await AccountAgent.update(account);
const response : Response.UnlinkProvider = {status:Response.Status.OK, message:{}};
res.json(response);
}
else
{
const response : Response.UnlinkProvider =
{
status: Response.Status.FAILED,
message: {general:R.text(R.CANNOT_UNLINK, locale)}
};
res.json(response);
}
}
while (false);
log.stepOut();
}
catch (err) {Utils.internalServerError(err, res, log);}
}
示例9: shouldAuthyUserDelete
/**
* Authyからユーザー削除するべきかどうか
*/
function shouldAuthyUserDelete(
account : Account,
prevInternationalPhoneNo : string,
newInternationalPhoneNo : string) : boolean
{
const log = slog.stepIn('onSetAccount.ts', 'shouldAuthyUserDelete');
let result = false;
do
{
if (account.authy_id === null)
{
log.d('Authy IDがないので削除の必要はありません。');
break;
}
if (prevInternationalPhoneNo === newInternationalPhoneNo)
{
log.d('電話番號に変更がないので削除の必要はありません。');
break;
}
log.d('削除が必要です。');
result = true;
}
while (false);
log.stepOut();
return result;
}
示例10: async
test.serial('パスワード変更の入力値検証 - メールアドレス以外に認証手段がある時はパスワードなしに変更できること', async (t) =>
{
const log = slog.stepIn('test', t['_test'].title);
let account : Account =
{
email: 'admin@example.com',
password: '12345678',
twitter: 'twitter'
};
account.password = Utils.getHashPassword(account.email, account.password, Config.PASSWORD_SALT);
account = await AccountAgent.add(account);
const param : Request.ChangePassword =
{
oldPassword: '12345678',
newPassword: null,
confirm: null,
};
const result = await isChangePasswordValid(param, account.id, locale);
const {status} = result.response;
t.is(status, Response.Status.OK);
await AccountAgent.remove(account.id);
log.stepOut();
});