How to use the plylog.getLogger function in plylog

To help you get started, we’ve selected a few plylog 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 Polymer / tools / packages / cli / src / run.ts View on Github external
* The complete set of contributors may be found at
 * http://polymer.github.io/CONTRIBUTORS.txt
 * Code distributed by Google as part of the polymer project is also
 * subject to an additional IP rights grant found at
 * http://polymer.github.io/PATENTS.txt
 */

// Be mindful of adding imports here, as this is on the hot path of all
// commands.

import * as logging from 'plylog';
import * as updateNotifier from 'update-notifier';
import {PolymerCli} from './polymer-cli';

const packageJson = require('../package.json');
const logger = logging.getLogger('cli.main');

// Update Notifier: Asynchronously check for package updates and, if needed,
// notify on the next time the CLI is run.
// See https://github.com/yeoman/update-notifier#how for info on how this works.
updateNotifier({pkg: packageJson}).notify();

(async () => {
  const args = process.argv.slice(2);
  const cli = new PolymerCli(args);
  try {
    const result = await cli.run();
    if (result && result.constructor &&
        result.constructor.name === 'CommandResult') {
      process.exit(result.exitCode);
    }
  } catch (err) {
github Polymer / polymer-cli / src / build / build.ts View on Github external
import * as bower from 'bower';
import * as path from 'path';
import * as logging from 'plylog';
import {dest} from 'vinyl-fs';

import mergeStream = require('merge-stream');
import {forkStream, PolymerProject, addServiceWorker, SWConfig, HtmlSplitter} from 'polymer-build';

import {getOptimizeStreams} from 'polymer-build';
import {ProjectBuildOptions} from 'polymer-project-config';
import {waitFor, pipeStreams} from './streams';
import {loadServiceWorkerConfig} from './load-config';
import {LocalFsPath} from 'polymer-build/lib/path-transformers';

const logger = logging.getLogger('cli.build.build');
export const mainBuildDirectoryName = 'build';

/**
 * Generate a single build based on the given `options` ProjectBuildOptions.
 * Note that this function is only concerned with that single build, and does
 * not care about the collection of builds defined on the config.
 */
export async function build(
    options: ProjectBuildOptions,
    polymerProject: PolymerProject): Promise {
  const buildName = options.name || 'default';
  // If no name is provided, write directly to the build/ directory.
  // If a build name is provided, write to that subdirectory.
  const buildDirectory = path.join(mainBuildDirectoryName, buildName);
  logger.debug(`"${buildDirectory}": Building with options:`, options);
github Polymer / polymer-cli / src / commands / serve.ts View on Github external
// the command is actually run, in order to minimize startup time from loading
// unused code. Any imports that are only used as types will be removed from the
// output JS and so not result in a require() statement.

import * as logging from 'plylog';
import {ProjectConfig} from 'polymer-project-config';
import * as polyserveTypeOnly from 'polyserve';
import {args as polyserveArgs} from 'polyserve/lib/args';
import {ServerOptions} from 'polyserve/lib/start_server';
import * as urlTypeOnly from 'url';

import {Environment} from '../environment/environment';

import {Command, CommandOptions} from './command';

const logger = logging.getLogger('cli.command.serve');

export class ServeCommand implements Command {
  name = 'serve';
  aliases = [];

  description = 'Runs the polyserve development server';

  args = polyserveArgs;

  async run(options: CommandOptions, config: ProjectConfig) {
    // Defer dependency loading until this specific command is run
    const polyserve = require('polyserve') as typeof polyserveTypeOnly;
    const startServers = polyserve.startServers;
    const getServerUrls = polyserve.getServerUrls;
    const url = require('url') as typeof urlTypeOnly;
github Polymer / polymer-cli / src / build / bundle.ts View on Github external
import * as dom5 from 'dom5';
import * as gulpif from 'gulp-if';
import * as path from 'path';
import {posix as posixPath} from 'path';
import {Transform} from 'stream';
import File = require('vinyl');
import * as logging from 'plylog';

import {StreamAnalyzer, DepsIndex} from './analyzer';
import {compose} from './streams';

// non-ES module
const minimatchAll = require('minimatch-all');
const through = require('through2').obj;
const Vulcanize = require('vulcanize');
let logger = logging.getLogger('cli.build.bundle');

export class Bundler extends Transform {

  entrypoint: string;
  root: string;
  shell: string;
  fragments: string[];
  allFragments: string[];

  sharedBundleUrl: string;

  analyzer: StreamAnalyzer;
  sharedFile: File;

  constructor(root: string, entrypoint: string,
      shell: string, fragments: string[], analyzer: StreamAnalyzer) {
github Polymer / tools / packages / cli / src / commands / serve.ts View on Github external
* http://polymer.github.io/PATENTS.txt
 */

// Be careful with these imports. As many as possible should be dynamic imports
// in the run method in order to minimize startup time from loading unused code.

import * as logging from 'plylog';
import {ProjectConfig} from 'polymer-project-config';
import {args as polyserveArgs} from 'polyserve/lib/args';
import {ServerOptions} from 'polyserve/lib/start_server';

import {Environment} from '../environment/environment';

import {Command, CommandOptions} from './command';

const logger = logging.getLogger('cli.command.serve');

export class ServeCommand implements Command {
  name = 'serve';
  aliases = [];

  description = 'Runs the polyserve development server';

  args = polyserveArgs;

  async run(options: CommandOptions, config: ProjectConfig) {
    // Defer dependency loading until this specific command is run
    const polyserve = await import('polyserve');
    const startServers = polyserve.startServers;
    const getServerUrls = polyserve.getServerUrls;
    const url = await import('url');
github Polymer / tools / packages / cli / src / build / build.ts View on Github external
import * as bower from 'bower';
import * as path from 'path';
import * as logging from 'plylog';
import {dest} from 'vinyl-fs';

import mergeStream = require('merge-stream');
import {forkStream, PolymerProject, addServiceWorker, SWConfig, HtmlSplitter} from 'polymer-build';

import {getOptimizeStreams} from 'polymer-build';
import {ProjectBuildOptions} from 'polymer-project-config';
import {waitFor, pipeStreams} from './streams';
import {loadServiceWorkerConfig} from './load-config';
import {LocalFsPath} from 'polymer-build/lib/path-transformers';

const logger = logging.getLogger('cli.build.build');
export const mainBuildDirectoryName = 'build';

/**
 * Generate a single build based on the given `options` ProjectBuildOptions.
 * Note that this function is only concerned with that single build, and does
 * not care about the collection of builds defined on the config.
 */
export async function build(
    options: ProjectBuildOptions,
    polymerProject: PolymerProject): Promise {
  const buildName = options.name || 'default';
  // If no name is provided, write directly to the build/ directory.
  // If a build name is provided, write to that subdirectory.
  const buildDirectory = path.join(mainBuildDirectoryName, buildName);
  logger.debug(`"${buildDirectory}": Building with options:`, options);
github Polymer / tools / packages / cli / src / commands / help.ts View on Github external
* http://polymer.github.io/PATENTS.txt
 */

// Be careful with these imports. As many as possible should be dynamic imports
// in the run method in order to minimize startup time from loading unused code.

import chalk from 'chalk';
import * as commandLineUsage from 'command-line-usage';
import * as logging from 'plylog';
import {ProjectConfig} from 'polymer-project-config';

import {globalArguments} from '../args';

import {Command, CommandOptions} from './command';

const logger = logging.getLogger('cli.command.help');

const b = chalk.blue;
const m = chalk.magenta;
const CLI_TITLE = chalk.bold.underline('Polymer-CLI');
const CLI_DESCRIPTION = 'The multi-tool for Polymer projects';
const CLI_USAGE = 'Usage: \`polymer  [options ...]\`';

const HELP_HEADER = `
   ${b('/\\\\˜˜/')}   ${m('/\\\\˜˜/')}${b('\\\\')}
  ${b('/__\\\\/')}   ${m('/__\\\\/')}${b('__\\\\')}    ${CLI_TITLE}
 ${b('/\\\\  /')}   ${m('/\\\\  /')}${b('\\\\  /\\\\')}
${b('/__\\\\/')}   ${m('/__\\\\/')}  ${b('\\\\/__\\\\')}  ${CLI_DESCRIPTION}
${b('\\\\  /\\\\')}  ${m('/\\\\  /')}   ${b('/\\\\  /')}
 ${b('\\\\/__\\\\')}${m('/__\\\\/')}   ${b('/__\\\\/')}   ${CLI_USAGE}
  ${b('\\\\')}  ${m('/\\\\  /')}   ${b('/\\\\  /')}
   ${b('\\\\')}${m('/__\\\\/')}   ${b('/__\\\\/')}
github Polymer / polymer-cli / src / build / optimize-streams.ts View on Github external
const babelPresetES2015NoModules =
    babelPresetES2015.buildPreset({}, {modules: false});
const externalHelpersPlugin = require('babel-plugin-external-helpers');
const babelObjectRestSpreadPlugin =
    require('babel-plugin-transform-object-rest-spread');
const babelPluginSyntaxDynamicImport =
    require('babel-plugin-syntax-dynamic-import');
const babelPluginSyntaxObjectRestSpread =
    require('babel-plugin-syntax-object-rest-spread');

// TODO(fks) 09-22-2016: Latest npm type declaration resolves to a non-module
// entity. Upgrade to proper JS import once compatible .d.ts file is released,
// or consider writing a custom declaration in the `custom_typings/` folder.
import File = require('vinyl');

const logger = logging.getLogger('cli.build.optimize-streams');

export type FileCB = (error?: any, file?: File) => void;
export type CSSOptimizeOptions = {
  stripWhitespace?: boolean;
};
export interface OptimizeOptions {
  html?: {
    minify?:
        boolean|{
          exclude?: string[]
        }
  };
  css?: {
    minify?:
        boolean|{
          exclude?: string[]
github Polymer / tools / packages / cli / src / build / load-config.ts View on Github external
* http://polymer.github.io/LICENSE.txt
 * The complete set of authors may be found at
 * http://polymer.github.io/AUTHORS.txt
 * The complete set of contributors may be found at
 * http://polymer.github.io/CONTRIBUTORS.txt
 * Code distributed by Google as part of the polymer project is also
 * subject to an additional IP rights grant found at
 * http://polymer.github.io/PATENTS.txt
 */


import * as fs from 'fs';
import * as logging from 'plylog';
import {SWConfig} from 'polymer-build';

const logger = logging.getLogger('cli.build.load-config');

export function loadServiceWorkerConfig(configFile: string):
    Promise {
  return new Promise((resolve, _reject) => {
    fs.stat(configFile, (statError) => {
      let config: SWConfig|null = null;
      // only log if the config file exists at all
      if (!statError) {
        try {
          config = require(configFile);
        } catch (loadError) {
          logger.warn(
              `${configFile} file was found but could not be loaded`,
              {loadError});
        }
      }
github Polymer / polymer-build / src / polymer-project.ts View on Github external
*/

import * as dom5 from 'dom5';
import * as osPath from 'path';
import * as logging from 'plylog';
import {Transform, PassThrough} from 'stream';
import File = require('vinyl');
import * as vfs from 'vinyl-fs';
import {StreamAnalyzer, DepsIndex} from './analyzer';
import {Bundler} from './bundle';
import {optimize, OptimizeOptions} from './optimize';
import {FileCB} from './streams';
import {writeServiceWorker, SWConfig} from './service-worker';
import {forkStream} from './fork-stream';

const logger = logging.getLogger('polymer-project');
const pred = dom5.predicates;

const extensionsForType: {[mimetype: string]: string} = {
  'text/ecmascript-6': 'js',
  'application/javascript': 'js',
  'text/javascript': 'js',
  'application/x-typescript': 'ts',
  'text/x-typescript': 'ts',
};

export interface ProjectOptions {
  /**
   * Path to the root of the project on the filesystem.
   */
  root?: string;

plylog

A logger for the Polymer CLI toolchain

BSD-3-Clause
Latest version published 6 years ago

Package Health Score

46 / 100
Full package analysis

Popular plylog functions