本文整理匯總了TypeScript中ng2-logger.Log類的典型用法代碼示例。如果您正苦於以下問題:TypeScript Log類的具體用法?TypeScript Log怎麽用?TypeScript Log使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Log類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: hello
//#region @backend
console.log('heeloa')
import * as path from 'path';
import * as _ from "lodash";
import "reflect-metadata";
import { createConnection, useContainer } from 'typeorm';
//#endregion
import { init, ENDPOINT, GET, Response } from 'morphi';
import { Log, Level } from 'ng2-logger';
const log = Log.create('main application')
const log2 = Log.create('auth module')
const log3 = Log.create('books module')
const log4 = Log.create("/Users/test/Projects/testProject/index.ts")
export class User {
name: string;
id: number;
friend: User;
}
@ENDPOINT({ path: '/hello' })
export class UserController {
@GET('/')
hello(): Response<User> {
let user = new User();
return { send: user }
示例2: DebugLog
import { Log } from 'ng2-logger';
export const log = Log.create('<%= conf.appNameKC %>');
log.color = 'black';
export function DebugLog(target: Object, key: string, descriptor: TypedPropertyDescriptor<any>) {
return {
value: function(...args: any[]) {
const result = descriptor.value.apply(this, args);
log.data(`Call: ${target.constructor.name}.${key}`, { arguments: args });
return result;
}
};
}
示例3:
import * as _ from 'lodash';
import { describe } from 'mocha'
import { expect, use } from 'chai'
import { CLASS } from 'typescript-class-helpers';
// import { BrowserDB } from '../browser-db/browser-db';
import { Mapping } from '../mapping'
import { encode } from 'punycode';
import { Log } from 'ng2-logger';
const log = Log.create('mapping test')
// const instance = BrowserDB.instance;
describe('Mapping inheritance', () => {
// @CLASS.NAME('Coffee')
class Coffee {
}
// @CLASS.NAME('Project')
@Mapping.DefaultModelWithMapping<Project>(void 0, {
cup: 'Coffee',
projectInside: 'Project'
})
class Project {
cup: Coffee;
projectInside: Project;
location: string;
示例4: children
import * as _ from 'lodash';
import { describe } from 'mocha'
import { expect, use } from 'chai'
import { Log } from 'ng2-logger';
const log = Log.create('Circural test');
// import { BrowserDB } from '../browser-db/browser-db';
import { Mapping } from '../mapping'
import { CLASS } from 'typescript-class-helpers';
@CLASS.NAME('Project')
export class Project {
browser: {
name: string;
location: string;
children: Project[];
parent: Project;
}
get children() {
return this.browser && this.browser.children;
}
get parent() {
return this.browser && this.browser.parent;
}