本文整理汇总了TypeScript中@asuna-admin/logger.createLogger函数的典型用法代码示例。如果您正苦于以下问题:TypeScript createLogger函数的具体用法?TypeScript createLogger怎么用?TypeScript createLogger使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了createLogger函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: createLogger
import { put, select, takeLatest } from 'redux-saga/effects';
import * as R from 'ramda';
import _ from 'lodash';
import { RootState } from '@asuna-admin/store';
import { createLogger } from '@asuna-admin/logger';
import { menuProxy } from '@asuna-admin/adapters';
const logger = createLogger('store:menu');
// --------------------------------------------------------------
// Module menuActionTypes
// --------------------------------------------------------------
const menuActionTypes = {
// ACTION: 'module::action'
INIT: 'menu::init',
INIT_SUCCESS: 'menu::init-success',
};
export const isMenuModule = action => action.type.startsWith('menu::') && !action.transient;
// --------------------------------------------------------------
// Module menuActions
// --------------------------------------------------------------
const menuActions = {
init: () => ({ type: menuActionTypes.INIT }),
};
开发者ID:danielwii,项目名称:asuna-admin,代码行数:30,代码来源:menu.redux.ts
示例2: query
/*
export interface IGraphQLService {
client: ApolloClient<any>;
serverClient: ApolloClient<any>;
query(queryString: string): Promise<any>;
queryT(query: string): Promise<any>;
loadSchemas(): Promise<any>;
}
*/
// --------------------------------------------------------------
// Main
// --------------------------------------------------------------
const logger = createLogger('adapters:graphql');
export class GraphqlAdapter {
public client: ApolloClient<any>;
public serverClient: ApolloClient<any>;
constructor(uri?: string) {
if (uri) {
this.client = new ApolloClient({ uri });
} else {
logger.log('graphql uri not defined, using /graphql for default');
this.client = new ApolloClient({ uri: '/graphql' });
}
this.serverClient = new ApolloClient({ uri: '/s-graphql' });
}
async query(queryString: string) {
开发者ID:danielwii,项目名称:asuna-admin,代码行数:30,代码来源:graphql.ts
示例3: createLogger
import { call, put, select, takeLatest } from 'redux-saga/effects';
import { reduxAction } from 'node-buffs';
import { message } from 'antd';
import * as R from 'ramda';
import { RootState } from './';
import { authActions } from './auth.actions';
import { createLogger } from '@asuna-admin/logger';
import { securityProxy } from '@asuna-admin/adapters';
import { toErrorMessage } from '@asuna-admin/helpers';
const logger = createLogger('store:security');
// --------------------------------------------------------------
// Module actionTypes
// --------------------------------------------------------------
const securityActionTypes = {
// ACTION: 'security::action'
LOAD_ALL_ROLES: 'security::load-all-roles',
LOAD_ALL_ROLES_SUCCESS: 'security::load-all-roles-success',
GET_CURRENT_USER: 'security::get-current-user',
GET_CURRENT_USER_SUCCESS: 'security::get-current-user-success',
UPDATE_PASSWORD: 'security::update-password',
};
const isSecurityModule = action => action.type.startsWith('security::') && !action.transient;
开发者ID:danielwii,项目名称:asuna-admin,代码行数:31,代码来源:security.redux.ts
示例4: createLogger
import { AxiosResponse } from 'axios';
import * as R from 'ramda';
import { createLogger } from '@asuna-admin/logger';
import idx from 'idx';
const logger = createLogger('helpers:errors');
interface FormError {
[key: string]: {
errors: {
field: string;
message: string;
}[];
};
}
// TODO move to node-buffs one day :)
export const reduxActionCallbackPromise = (action): Promise<any> =>
new Promise((resolve, reject) => {
const callback = ({ response, error }) => (response ? resolve(response) : reject(error));
action(callback);
});
export type ReduxCallback<T> = (data: { response: T; error: Error }) => void;
export function safeCallback(cb, data) {
try {
if (cb != null) cb(data);
} catch (e) {
logger.warn('callback error', e, { e });
开发者ID:danielwii,项目名称:asuna-admin,代码行数:31,代码来源:error.ts
示例5: createLogger
import * as _ from 'lodash';
import { isJson } from '@asuna-admin/helpers';
import { createLogger } from '@asuna-admin/logger';
import { Config } from '@asuna-admin/config';
import { AppContext } from '.';
const logger = createLogger('core:url-rewriter');
export function valueToArrays(value) {
const castToArrays = value =>
isJson(value) ? JSON.parse(value as string) : _.compact(value.split(','));
const images = value ? (_.isArray(value) ? value : castToArrays(value)) : [];
logger.debug('[valueToArrays]', { value, images });
return images;
}
export function valueToUrl(
value,
{
host,
type,
thumbnail,
}: {
host?: string;
type?: 'image' | 'video' | 'attache' | 'file';
thumbnail?: { width?: number; height?: number };
},
) {
if (value) {
const hostPrefix =
host ||
开发者ID:danielwii,项目名称:asuna-admin,代码行数:31,代码来源:url-rewriter.ts
示例6: createLogger
import { message } from 'antd';
import { apiProxy } from '@asuna-admin/adapters';
import { createLogger } from '@asuna-admin/logger';
import { AxiosRequestConfig } from 'axios';
const logger = createLogger('helpers:upload');
export async function getBase64(image): Promise<string | ArrayBuffer | null> {
const reader = new FileReader();
return new Promise((resolve, reject) => {
reader.addEventListener('load', () => (reader.result ? resolve(reader.result) : resolve()));
reader.addEventListener('error', ev => reject(ev));
reader.readAsDataURL(image);
});
}
export function validateFile(file: { type: string; size: number }): boolean {
// console.log(file);
const isImage = ['image/jpeg', 'image/png', 'image/gif'].indexOf(file.type) > -1;
const isLt20M = file.size / 1024 / 1024 < 20;
logger.log('[validateFile]', file, { isImage, isLt20M });
if (!isImage) {
message.error('You can only upload JPG/PNG/GIF file!');
}
if (!isLt20M) {
message.error('Image must smaller than 20MB!');
}
return isImage && isLt20M;
}
export async function upload(
开发者ID:danielwii,项目名称:asuna-admin,代码行数:31,代码来源:upload.ts
示例7: createLogger
import * as R from 'ramda';
import { message } from 'antd';
import { REHYDRATE } from 'redux-persist';
import { authActions, authActionTypes, isAuthModule } from './auth.actions';
import { appActionTypes, RootState } from './';
import { panesActions } from './panes.actions';
import { routerActions } from './router.redux';
import { createLogger } from '@asuna-admin/logger';
import { authProxy } from '@asuna-admin/adapters';
import { toErrorMessage } from '@asuna-admin/helpers';
import idx from 'idx';
const logger = createLogger('store:auth');
// --------------------------------------------------------------
// Login sagas
// --------------------------------------------------------------
function* loginSaga({ payload: { username, password }, callback }) {
const auth: AuthState = yield select((state: RootState) => state.auth);
try {
const response = yield call(authProxy.login, username, password);
logger.log('[loginSaga]', 'response is', response);
// 切换用户时更新操作区域,如果未来需要保存当前页面配置的话,应该将切换操作提出为单独的 Saga
if (auth.username !== username) {
yield put(panesActions.closeAll());
}
开发者ID:danielwii,项目名称:asuna-admin,代码行数:31,代码来源:auth.redux.ts
示例8: createLogger
import { connect, Socket } from 'socket.io-client';
import { appActions } from '@asuna-admin/store';
import { AppContext } from '@asuna-admin/core';
import { createLogger } from '@asuna-admin/logger';
// --------------------------------------------------------------
// Main
// --------------------------------------------------------------
const logger = createLogger('adapters:ws');
export class WsAdapter {
private port?: number;
private namespace: string;
private static io: typeof Socket;
constructor(opts: { port?: number; namespace?: string } = {}) {
this.port = opts.port;
this.namespace = opts.namespace || 'admin';
if (!AppContext.isServer && !WsAdapter.io) {
WsAdapter.io = connect(
'/admin',
{ secure: true, reconnectionDelay: 10e3, reconnectionDelayMax: 60e3 },
);
WsAdapter.io.on('connect', () => {
logger.log('[connect]', { id: WsAdapter.io.id, AppContext });
AppContext.dispatch(appActions.heartbeat());
开发者ID:danielwii,项目名称:asuna-admin,代码行数:31,代码来源:ws.ts
示例9: createLogger
import { call, put, select, takeLatest } from 'redux-saga/effects';
import { message } from 'antd';
import { reduxAction } from 'node-buffs';
import * as R from 'ramda';
import _ from 'lodash';
import { AxiosResponse } from 'axios';
import { contentActions, RootState } from '@asuna-admin/store';
import { createLogger } from '@asuna-admin/logger';
import { AppContext } from '@asuna-admin/core';
import { ReduxCallback, safeCallback, toErrorMessage } from '@asuna-admin/helpers';
const logger = createLogger('store:models');
// --------------------------------------------------------------
// Module actionTypes
// --------------------------------------------------------------
const modelsActionTypes = {
// ACTION: 'module::action'
FETCH: 'models::fetch',
FETCH_SUCCESS: 'models::fetch-success',
UPSERT: 'models::upsert',
REMOVE: 'models::remove',
LOAD_ALL_SCHEMAS: 'models::load-all-schemas',
LOAD_ALL_SCHEMAS_SUCCESS: 'models::load-all-schemas-success',
};
export const isModelModule = action => action.type.startsWith('models::') && !action.transient;
// --------------------------------------------------------------
开发者ID:danielwii,项目名称:asuna-admin,代码行数:31,代码来源:models.redux.ts
示例10: createLogger
import _ from 'lodash';
import * as R from 'ramda';
import idx from 'idx';
import { DynamicFormTypes } from '@asuna-admin/components';
import { castModelKey, castModelName, diff } from '@asuna-admin/helpers';
import { createLogger } from '@asuna-admin/logger';
import { AppContext } from '@asuna-admin/core';
const logger = createLogger('helpers:schema');
export const peek = (message, callback?) => fields => {
if (callback) callback();
logger.log('[peek]', { message, fields });
return fields;
};
export type Fields = {
[key: string]: {
name: string;
ref: string;
type: string;
value?: any;
options: {
name: string;
type: DynamicFormTypes;
label: string | null;
length: number | null;
required: boolean;
selectable?: string;
jsonType?: string;
开发者ID:danielwii,项目名称:asuna-admin,代码行数:31,代码来源:index.ts
注:本文中的@asuna-admin/logger.createLogger函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论