Skip to content

Commit

Permalink
feat(*): Tweak debugLog output into columns
Browse files Browse the repository at this point in the history
  • Loading branch information
christopherthielen committed Nov 14, 2018
1 parent 94fe097 commit ac0dda2
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/angularjs/ReactUIViewAdapterComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ hybridModule.directive('uiView', function() {
compile: function(tElem, tAttrs) {
let { name, uiView } = tAttrs;
name = name || uiView || '$default';
debugLog('angularjs ui-view', '', '.compile()', 'Creating react-ui-view-adapter', tElem);
debugLog('angularjs', 'ui-view', '?', '.compile()', 'Creating react-ui-view-adapter', tElem);
tElem.html(`<react-ui-view-adapter name="${name}"></react-ui-view-adapter>`);
},
};
Expand All @@ -28,7 +28,7 @@ hybridModule.directive('reactUiViewAdapter', function() {
restrict: 'E',
link: function(scope, elem, attrs) {
const debug = (method: string, message: string, ...args) =>
debugLog('angularjs react-ui-view-adapter', `${$id}/${attrs.name}`, method, message, ...args);
debugLog('angularjs', 'react-ui-view-adapter', `${$id}/${attrs.name}`, method, message, ...args);

const el = elem[0];
let _ref = null;
Expand Down
19 changes: 17 additions & 2 deletions src/debug.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
export const debug = (component: string, id: string, method: string, message: string, ...args) => {
import { padString } from '@uirouter/core';

export const debug = (
angularOrReact: 'angularjs' | 'react',
component: string,
id: string,
method: string,
message: string,
...args
) => {
if (window && window['debugReactHybrid'] !== true) return;
console.log(`${component}[${id}]${method}: ${message}`, ...args);
console.log(
`${padString(12, angularOrReact)} ${padString(40, `${component}[${id}]`)} ${padString(
35,
`${method}:`
)} ${message}`,
...args
);
};
2 changes: 1 addition & 1 deletion src/react/ReactUIView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { debug as debugLog } from '../debug';
const InternalUIView = UIView.__internalViewComponent;

const ReactUIView = ({ refFn, ...props }) => {
debugLog('react ReactUIView', `?/${props['name']}`, '.render()', '');
debugLog('react', 'ReactUIView', `?/${props['name']}`, '.render()', '');

return (
<UIRouterContextComponent parentContextLevel="3" inherited={false}>
Expand Down
4 changes: 2 additions & 2 deletions src/react/UIViewMonkeyPatch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class PortalView extends React.PureComponent {
};

private debug = (method: string, message: string, ...args) =>
debugLog('react PortalView', `${this.$id}/${this.props['name']}`, method, message, ...args);
debugLog('react', 'PortalView', `${this.$id}/${this.props['name']}`, method, message, ...args);

public componentWillUnmount() {
this.debug('.componentWillUnmount()', '');
Expand Down Expand Up @@ -74,7 +74,7 @@ class PortalView extends React.PureComponent {

UIView.prototype.render = function() {
if (this.props.wrap === false) {
debugLog('react UIView', `${this.$id}/${this.props['name']}`, '.render()', 'realRender.apply(this, arguments)');
debugLog('react', 'UIView', `${this.$id}/${this.props['name']}`, '.render()', 'realRender.apply(this, arguments)');
return <div className="UIView">{realRender.apply(this, arguments)}</div>;
}

Expand Down

0 comments on commit ac0dda2

Please sign in to comment.