Move Logger to metro-core

Reviewed By: rafeca

Differential Revision: D6568129

fbshipit-source-id: fc367c45e22ef58436331e1a6347ec16f1f155a0
This commit is contained in:
Peter van der Zee 2017-12-15 06:21:18 -08:00 committed by Facebook Github Bot
parent 1d12090bc3
commit 4586152ebf
15 changed files with 54 additions and 54 deletions

View File

@ -18,7 +18,26 @@ const {EventEmitter} = require('events');
const VERSION = require('../../package.json').version;
import type {ActionLogEntryData, ActionStartLogEntry, LogEntry} from './Types';
type ActionLogEntryData = {
action_name: string,
};
type ActionStartLogEntry = {
action_name?: string,
action_phase?: string,
log_entry_label: string,
log_session?: string,
start_timestamp?: [number, number],
};
export type LogEntry = {
action_name?: string,
action_phase?: string,
duration_ms?: number,
log_entry_label: string,
log_session?: string,
start_timestamp?: [number, number],
};
const log_session = `${os.hostname()}-${Date.now()}`;
const eventEmitter = new EventEmitter();

View File

@ -0,0 +1,19 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @flow
* @format
*/
'use strict';
const Logger = require('./Logger');
export type {LogEntry} from './Logger';
module.exports = Logger;

View File

@ -12,11 +12,13 @@
'use strict';
const Logger = require('./Logger');
const Terminal = require('./Terminal');
const formatBanner = require('./formatBanner');
module.exports = {
Logger,
Terminal,
formatBanner,
};

View File

@ -23,7 +23,7 @@ jest
.mock('../../node-haste/DependencyGraph')
.mock('../../JSTransformer')
.mock('../../Resolver')
.mock('../../Logger')
.mock('metro-core')
.mock('/path/to/transformer.js', () => ({}), {virtual: true});
var Bundler = require('../');

View File

@ -16,7 +16,7 @@ jest.useRealTimers();
jest
.mock('fs')
.mock('graceful-fs')
.mock('../../Logger')
.mock('metro-core')
.mock('../../lib/TransformCaching')
// It's noticeably faster to prevent running watchman from FileWatcher.
.mock('child_process', () => ({}))

View File

@ -19,10 +19,8 @@ const querystring = require('querystring');
const url = require('url');
const {
createActionStartEntry,
createActionEndEntry,
log,
} = require('../Logger');
Logger: {createActionStartEntry, createActionEndEntry, log},
} = require('metro-core');
import type DeltaTransformer from '../DeltaBundler/DeltaTransformer';
import type PackagerServer from '../Server';

View File

@ -12,7 +12,7 @@
'use strict';
const Logger = require('../Logger');
const {Logger} = require('metro-core');
const debug = require('debug')('Metro:JStransformer');
const Worker = require('jest-worker').default;

View File

@ -26,7 +26,7 @@ const path = require('path');
const {compactMapping} = require('metro-source-map');
import type {LogEntry} from '../../Logger/Types';
import type {LogEntry} from 'metro-core/src/Logger';
import type {CompactRawMappings, MappingsMap} from '../../lib/SourceMap';
import type {LocalPath} from '../../node-haste/lib/toLocalPath';
import type {ResultWithMap} from './minify';

View File

@ -1,34 +0,0 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @flow
* @format
*
*/
'use strict';
export type ActionLogEntryData = {
action_name: string,
};
export type ActionStartLogEntry = {
action_name?: string,
action_phase?: string,
log_entry_label: string,
log_session?: string,
start_timestamp?: [number, number],
};
export type LogEntry = {
action_name?: string,
action_phase?: string,
duration_ms?: number,
log_entry_label: string,
log_session?: string,
start_timestamp?: [number, number],
};

View File

@ -22,7 +22,7 @@ jest
.mock('../../Bundler')
.mock('../../Assets')
.mock('../../node-haste/DependencyGraph')
.mock('../../Logger')
.mock('metro-core/src/Logger')
.mock('../../lib/GlobalTransformCache')
.mock('../../DeltaBundler/Serializers');

View File

@ -46,10 +46,8 @@ import type {AssetData} from '../Assets';
import type {RamBundleInfo} from '../DeltaBundler/Serializers';
import type {PostProcessModules} from '../DeltaBundler';
const {
createActionStartEntry,
createActionEndEntry,
log,
} = require('../Logger');
Logger: {createActionStartEntry, createActionEndEntry, log},
} = require('metro-core');
function debounceAndBatch(fn, delay) {
let args = [];

View File

@ -12,13 +12,13 @@
'use strict';
const Logger = require('./Logger');
const TransformCaching = require('./lib/TransformCaching');
const blacklist = require('./blacklist');
const debug = require('debug');
const invariant = require('fbjs/lib/invariant');
const {Logger} = require('metro-core');
const {fromRawMappings, compactMapping} = require('metro-source-map');
import type {ConfigT as MetroConfig} from './Config';

View File

@ -26,13 +26,11 @@ const parsePlatformFilePath = require('./lib/parsePlatformFilePath');
const path = require('path');
const util = require('util');
const {
createActionEndEntry,
createActionStartEntry,
log,
} = require('../Logger');
const {ModuleResolver} = require('./DependencyGraph/ModuleResolution');
const {EventEmitter} = require('events');
const {
Logger: {createActionStartEntry, createActionEndEntry, log},
} = require('metro-core');
import type {Options as JSTransformerOptions} from '../JSTransformer/worker';
import type {GlobalTransformCache} from '../lib/GlobalTransformCache';