Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default logger is broken in 0.5.3 #328

Closed
IvoB1987 opened this issue Nov 22, 2022 · 2 comments · Fixed by #337
Closed

Default logger is broken in 0.5.3 #328

IvoB1987 opened this issue Nov 22, 2022 · 2 comments · Fixed by #337
Labels
bug Something isn't working

Comments

@IvoB1987
Copy link
Contributor

Describe the bug
Not defining a custom Logger makes it use the PrettyPrinter of the logger package instead MyLogPrinter provided by this package. Also loggingLevel has no effect because of this.

To Reproduce
Do anything that causes a log. Do not use a custom logger. Also notice that changing loggingLevel doesn't do anything

Expected behavior
I expect it to work like in 0.5.2 or before. Now, it's not using the provided methods of the Log class anymore, (like debug, warn etc.) therefore bypassing the autoInit and the factories.

System Infomation()
Flutter SDK Version: Flutter (Channel stable, 3.3.8)
Target OS and Version: (flutter web) Chrome Version 107.0.5304.107 (Official Build) (64-bit)
Host OS and Version: Microsoft Windows [Version 10.0.19044.2251]

@IvoB1987 IvoB1987 added the bug Something isn't working label Nov 22, 2022
@IvoB1987
Copy link
Contributor Author

IvoB1987 commented Nov 22, 2022

The current code of the Log class seems also very strange to me and overly complicated. I refactored it myself locally to this to solve this bug and also making the class much simpler:

Logger logger = Log();
class Log extends Logger {
  Log(): super(printer: MyLogPrinter('.')) {
    StackTraceNJ frames = StackTraceNJ();

    if (frames.frames != null) {
      for (Stackframe frame in frames.frames!) {
        _localPath = frame.sourceFile.path
            .substring(frame.sourceFile.path.lastIndexOf('/'));
        break;
      }
    }
  }

  static late String _localPath;
  static Level _loggingLevel = Level.debug;
  static set loggingLevel(Level loggingLevel) => _loggingLevel = loggingLevel;
}

I think this will result with identical behavior as before without all unnecessary factories and other overcomplications. It also revealed some spots in the package where the logger was called incorrectly, like Log.d instead of logger.d

@ghenry
Copy link
Collaborator

ghenry commented Jan 1, 2023

Fancy a pull request?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants