Repository: uber-go/fx
Pull request #877 (2022-05-04 21:45:17)

Ensure args match verbs in ConsoleLogger
Fix the format call for `Supplied` event.

Previously, `\n%!(EXTRA string=)` was appended to `SUPPLY` logs when
`ModuleName` was empty.

Add tests to ensure format string contains the same number of verbs as
there are arguments when logging an `Event` using `ConsoleLogger` for
all relevant event types,

Module info was added to fxevent in #863.

codecov[bot]: # [Codecov](https://codecov.io/gh/uber-go/fx/pull/877?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=uber-go) Report
> Merging [#877](https://codecov.io/gh/uber-go/fx/pull/877?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=uber-go) (b69e09d) into [master](https://codecov.io/gh/uber-go/fx/commit/81f070ebf4db26fa0220adcfc16defdb7c855cb6?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=uber-go) (81f070e) will **not change** coverage.
> The diff coverage is `100.00%`.

```diff
@@           Coverage Diff           @@
##           master     #877   +/-   ##
=======================================
  Coverage   98.53%   98.53%           
=======================================
  Files          30       30           
  Lines        1157     1157           
=======================================
  Hits         1140     1140           
  Misses         11       11           
  Partials        6        6           
```


| [Impacted Files](https://codecov.io/gh/uber-go/fx/pull/877?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=uber-go) | Coverage Δ | |
|---|---|---|
| [fxevent/console.go](https://codecov.io/gh/uber-go/fx/pull/877/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=uber-go#diff-ZnhldmVudC9jb25zb2xlLmdv) | `100.00% <100.00%> (ø)` | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/uber-go/fx/pull/877?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=uber-go).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=uber-go)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/uber-go/fx/pull/877?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=uber-go). Last update [81f070e...b69e09d](https://codecov.io/gh/uber-go/fx/pull/877?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=uber-go). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=uber-go).


Patch:
diff --git a/fxevent/console.go b/fxevent/console.go
index b22ff1a..cb777cb 100644
--- a/fxevent/console.go
+++ b/fxevent/console.go
@@ -65,7 +65,7 @@ func (l *ConsoleLogger) LogEvent(event Event) {
 		} else if e.ModuleName != "" {
 			l.logf("SUPPLY\t%v from module %q", e.TypeName, e.ModuleName)
 		} else {
-			l.logf("SUPPLY\t%v", e.TypeName, e.ModuleName)
+			l.logf("SUPPLY\t%v", e.TypeName)
 		}
 	case *Provided:
 		for _, rtype := range e.OutputTypeNames {


Test patch:
diff --git a/fxevent/console_test.go b/fxevent/console_test.go
index 0e95ce4..7cae131 100644
--- a/fxevent/console_test.go
+++ b/fxevent/console_test.go
@@ -137,6 +137,11 @@ func TestConsoleLogger(t *testing.T) {
 		},
 		{
 			name: "Supplied",
+			give: &Supplied{TypeName: "*bytes.Buffer"},
+			want: "[Fx] SUPPLY	*bytes.Buffer\n",
+		},
+		{
+			name: "Supplied with module",
 			give: &Supplied{TypeName: "*bytes.Buffer", ModuleName: "myModule"},
 			want: "[Fx] SUPPLY	*bytes.Buffer from module \"myModule\"\n",
 		},
@@ -152,6 +157,14 @@ func TestConsoleLogger(t *testing.T) {
 		},
 		{
 			name: "Provided",
+			give: &Provided{
+				ConstructorName: "bytes.NewBuffer()",
+				OutputTypeNames: []string{"*bytes.Buffer"},
+			},
+			want: "[Fx] PROVIDE	*bytes.Buffer <= bytes.NewBuffer()\n",
+		},
+		{
+			name: "Provided with module",
 			give: &Provided{
 				ConstructorName: "bytes.NewBuffer()",
 				ModuleName:      "myModule",
@@ -161,6 +174,13 @@ func TestConsoleLogger(t *testing.T) {
 		},
 		{
 			name: "Replaced",
+			give: &Replaced{
+				OutputTypeNames: []string{"*bytes.Buffer"},
+			},
+			want: "[Fx] REPLACE	*bytes.Buffer\n",
+		},
+		{
+			name: "Replaced with module",
 			give: &Replaced{
 				ModuleName:      "myModule",
 				OutputTypeNames: []string{"*bytes.Buffer"},
@@ -174,6 +194,14 @@ func TestConsoleLogger(t *testing.T) {
 		},
 		{
 			name: "Decorated",
+			give: &Decorated{
+				DecoratorName:   "bytes.NewBuffer()",
+				OutputTypeNames: []string{"*bytes.Buffer"},
+			},
+			want: "[Fx] DECORATE	*bytes.Buffer <= bytes.NewBuffer()\n",
+		},
+		{
+			name: "Decorated with module",
 			give: &Decorated{
 				DecoratorName:   "bytes.NewBuffer()",
 				ModuleName:      "myModule",
@@ -196,6 +224,14 @@ func TestConsoleLogger(t *testing.T) {
 			give: &Invoking{FunctionName: "bytes.NewBuffer()"},
 			want: "[Fx] INVOKE		bytes.NewBuffer()\n",
 		},
+		{
+			name: "Invoking with module",
+			give: &Invoking{
+				FunctionName: "bytes.NewBuffer()",
+				ModuleName:   "myModule",
+			},
+			want: "[Fx] INVOKE		bytes.NewBuffer() from module \"myModule\"\n",
+		},
 		{
 			name: "Invoked/Error",
 			give: &Invoked{