How to use @faasjs/logger - 10 common examples

To help you get started, we’ve selected a few @faasjs/logger examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github faasjs / faasjs / packages / cli / src / index.ts View on Github external
import Logger from '@faasjs/logger';
import { existsSync } from 'fs';
import { sep } from 'path';
import New from './commands/new';
import Deploy from './commands/deploy';
import Server from './commands/server';

require('ts-node').register({
  project: process.cwd() + '/tsconfig.json',
  compilerOptions: {
    module: 'commonjs'
  }
});

const commander: Command = new Command();
const logger = new Logger('Cli');

// 设置命令
commander
  .version('beta')
  .usage('[command] [flags]')
  .option('-v --verbose', '显示调试日志')
  .option('-r --root 
github faasjs / faasjs / packages / deployer / src / index.ts View on Github external
constructor (data: DeployData) {
    data.name = data.filename.replace(data.root, '').replace('.func.ts', '').replace(/^\/?[^/]+\//, '').replace(/\/$/, '');
    data.version = new Date().toLocaleString('zh-CN', {
      hour12: false,
      timeZone: 'Asia/Shanghai',
    }).replace(/(\/|:|\s)/g, '_');

    data.logger = new Logger('Deployer');

    const Config = loadConfig(data.root, data.filename);

    if (!data.env) {
      data.env = process.env.FaasEnv || Config.defaults.deploy.env;
    }

    data.config = Config[data.env!];

    if (!data.config) {
      throw Error(`Config load failed: ${data.env}`);
    }

    data.tmp = `${data.root}/tmp/${data.env}/${data.name}/${data.version}/`;

    data.tmp.split('/').reduce(function (acc: string, cur: string) {
github faasjs / faasjs / packages / func / src / index.ts View on Github external
constructor (config: {
    plugins?: Plugin[];
    handler: Handler;
  }) {
    this.logger = new Logger('Func');

    if (typeof config.handler !== 'function') {
      throw Error('Unknown handler');
    }
    this.handler = config.handler;

    this.plugins = config.plugins || [];
    this.plugins.push(new RunHandler());
    this.config = {
      providers: Object.create(null),
      plugins: Object.create(null)
    };

    this.mounted = false;
    this.cachedFunctions = Object.create(null);
  }
github faasjs / faasjs / packages / sql / src / index.ts View on Github external
constructor (config?: {
    name?: string;
    adapterType?: string;
    config?: SqlConfig;
  }) {
    this.type = 'sql';

    if (config) {
      this.name = config.name || 'sql';
      this.adapterType = config.adapterType;
      this.config = config.config || Object.create(null);
    } else {
      this.name = 'sql';
      this.config = Object.create(null);
    }
    this.logger = new Logger('Sql');
  }
github faasjs / faasjs / packages / cli / src / commands / new.ts View on Github external
export function action (type: string, name: string, plguins: string[]) {
  const logger = new Logger();

  switch (type) {
    case 'func':
      newFunc(logger, name, plguins);
      break;
    default:
      logger.error(`Unknown type: ${type} (should be func)`);
      break;
  }
}
github faasjs / faasjs / packages / cloud_function / src / index.ts View on Github external
constructor (config: CloudFunctionConfig = Object.create(null)) {
    this.logger = new Logger('CloudFunction');
    this.type = 'cloud_function';
    this.name = config.name;
    this.config = config.config || Object.create(null);
    if (config.validator) {
      this.validatorConfig = config.validator;
    }
  }
github faasjs / faasjs / packages / cloud_function / src / validator.ts View on Github external
constructor (config: {
    event?: ValidatorConfig;
  }) {
    this.eventConfig = config.event;
    this.logger = new Logger('CloudFunction.Validator');
  }
github faasjs / faasjs / packages / request / src / index.ts View on Github external
import * as http from 'http';
import * as https from 'https';
import { stringify } from 'querystring';
import * as URL from 'url';
import Logger from '@faasjs/logger';

const log = new Logger('request');

export interface Request {
  headers?: http.OutgoingHttpHeaders;
  method?: string;
  host?: string;
  path?: string;
  query?: http.OutgoingHttpHeaders;
  body?: any;
}

export interface Response {
  request?: Request;
  statusCode?: number;
  statusMessage?: string;
  headers: http.OutgoingHttpHeaders;
  body: any;
github faasjs / faasjs / packages / tencentcloud / src / index.ts View on Github external
constructor (config: TencentcloudConfig) {
    this.config = config;
    this.logger = new Logger('Tencentcloud');
  }
  /**
github faasjs / faasjs / packages / server / src / index.ts View on Github external
constructor (root: string, opts?: {
    cache: boolean;
  }) {
    this.root = root.endsWith(sep) ? root : root + sep;
    this.logger = new Logger('Server');
    this.opts = Object.assign({
      cache: false
    }, opts || {});
    this.cachedFuncs = {};
    this.logger.debug('init with %s %o', this.root, this.opts);
  }

@faasjs/logger

FaasJS's logger module.

MIT
Latest version published 3 days ago

Package Health Score

78 / 100
Full package analysis

Popular @faasjs/logger functions