Closed derian-all-win-software closed 1 year ago
Hello @derian-all-win-software
can you please show me the content of the file WinstonLogger
Remember, every single service/dependency needs to be exported as default or use https://github.com/zazoomauro/node-dependency-injection/wiki/NamedMultiple
Hi @zazoomauro, this is the content of the WistonLogger
class:
import winston, { Logger as WinstonLoggerType } from 'winston';
import Logger from '../domain/Logger';
enum Levels {
DEBUG = 'debug',
ERROR = 'error',
INFO = 'info'
}
class WinstonLogger implements Logger {
private logger: WinstonLoggerType;
constructor() {
this.logger = winston.createLogger({
format: winston.format.combine(
winston.format.prettyPrint(),
winston.format.errors({ stack: true }),
winston.format.splat(),
winston.format.colorize(),
winston.format.simple()
),
transports: [
new winston.transports.Console(),
new winston.transports.File({ filename: `logs/${Levels.DEBUG}.log`, level: Levels.DEBUG }),
new winston.transports.File({ filename: `logs/${Levels.ERROR}.log`, level: Levels.ERROR }),
new winston.transports.File({ filename: `logs/${Levels.INFO}.log`, level: Levels.INFO })
]
});
}
debug(message: string) {
this.logger.debug(message);
}
error(message: string | Error) {
this.logger.error(message);
}
info(message: string) {
this.logger.info(message);
}
}
export default WinstonLogger;
The Logger interface would look like this:
export default interface Logger {
debug(message: string): void;
error(message: string | Error): void;
info(message: string): void;
}
It looks good...
so the issue seems to be related with the real path. can you please try to follow this in order to avoid ......... hell https://github.com/zazoomauro/node-dependency-injection/wiki/CustomRelativeServiceDirectory
Hey @zazoomauro, this has solved the problem for me, thank you very much for the help.
Version
I have used two versions of the libraries, the first one is
2.6.11
and the other one is3.0.3
being the newer release, in both the error occurs.Error
Description
When I use
ContainerBuilder
with theYamlFileLoader
class as follows:when trying to resolve the paths from the Yaml file it is not able to resolve them, I use a file called
application.yaml
where I simply do the necessary imports from my other*.yaml
files that have the paths to the necessary classes, it would be something like this:I have made sure that the file path is correct but I still can't resolve the classes, I tried to register the classes using the
register
method and that way it works using the same file path.