Skip to content

Commit 3a80fc8

Browse files
committed
use simple method factory copy AND childLogger.setLevel(childLogger.getLevel());
This is the important part that actually registers the new methods.
1 parent 4d7ab1c commit 3a80fc8

File tree

1 file changed

+2
-12
lines changed

1 file changed

+2
-12
lines changed

src/logger.ts

+2-12
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ See the License for the specific language governing permissions and
1515
limitations under the License.
1616
*/
1717

18-
import loglevel, { LoggingMethod } from "loglevel";
18+
import loglevel from "loglevel";
1919

2020
/** Backwards-compatibility hack to expose `log` to applications that might still be relying on it. */
2121
interface LoggerWithLogMethod extends Logger {
@@ -137,18 +137,8 @@ function getPrefixedLogger(prefix?: string): LoggerWithLogMethod {
137137
prefixLogger.prefix = prefix;
138138
prefixLogger.getChild = (childPrefix): Logger => {
139139
const childLogger = getPrefixedLogger((prefix ?? "") + childPrefix) as unknown as loglevel.Logger;
140-
childLogger.methodFactory = (methodName, configLevel, loggerName): LoggingMethod => {
141-
const method = (logger as unknown as loglevel.Logger).methodFactory(
142-
methodName,
143-
configLevel,
144-
loggerName,
145-
);
146-
return (...args): void => {
147-
method.apply(childLogger, args);
148-
};
149-
};
140+
childLogger.methodFactory = (logger as unknown as loglevel.Logger).methodFactory;
150141
childLogger.setLevel(childLogger.getLevel());
151-
152142
return childLogger as unknown as Logger;
153143
};
154144
prefixLogger.setLevel(loglevel.levels.DEBUG, false);

0 commit comments

Comments
 (0)