What happened to my `logging` package?

150 views
Skip to first unread message

Eric Bullington

unread,
Dec 6, 2013, 2:30:16 PM12/6/13
to mi...@dartlang.org
I decided to go with Dart on both server and client for a new project.  I'm thoroughly enjoying the language, but am having some problems with the build environment.  My latest problem, and one that has now consumed over 2 hours, is that my "Logger" import from the `logging` package is suddenly no longer working.  I'm sure I'm missing something obvious, but I'm just not able to get it working again.

To be sure it wasn't just some problem with my current project, I created a new test project and I'm unable to import Logger into that project either.

The error messages I'm getting:

  'file:///home/****/main/scripts/dart/altapp/bin/main.dart': Error: line 5 pos 1: unexpected token 'Logger'
  Logger.root.level = Level.ALL;

In my other project, I was getting `library handler failed` error messages regarding the `logging` package.

(doesn't matter how I use "Logger", the first reference to it always gets these kinds of errors)

The odd thing is that the logging/logging.dart file is sitting right there in my packages directory, yet I still get the missing library messages.

So here are the steps I've taken to solve the problem:

1. Delete my "packages" directory and re-run `pub get` and `pub install`
2. Delete the ~/.pub-cache directory and then re-run `pub get` and `pub install`
3. Try various different versions of the Logger package
4. Checked file permissions, and various other fiddling, to no avail

Does anyone have any ideas what may have gone wrong?  

On a related note, I think it'd be a great idea to put the logging package in the core library, or in `dart:io` (not clear to me if dart:io is part of the core library).

Thanks for a great project!  I hope I'm able to straighten things out enough to be able to use Dart for this project, since I'm really enjoying the language.  I'm sure I've made some stupid error, but I really have no idea what.

Thank you,

Eric

Allan MacDonald

unread,
Dec 6, 2013, 2:48:27 PM12/6/13
to General Dart Discussion
Eric,

Have you added any additional package import statements recently. There may be another import that is in turn importing that library and confusing the editor. I have had some success in the past by commenting out (temporarily) some of the packages to see if the Logger begins to be recognized again.

Allan


--
For other discussions, see https://groups.google.com/a/dartlang.org/
 
For HOWTO questions, visit http://stackoverflow.com/tags/dart
 
To file a bug report or feature request, go to http://www.dartbug.com/new

To unsubscribe from this group and stop receiving emails from it, send an email to misc+uns...@dartlang.org.

Peter Ahé

unread,
Dec 6, 2013, 2:55:11 PM12/6/13
to General Dart Discussion
Is a colon missing on line 4?

Cheers,
Peter

Eric Bullington

unread,
Dec 6, 2013, 10:34:25 PM12/6/13
to mi...@dartlang.org
On Fri, Dec 6, 2013 at 2:55 PM, Peter Ahé <a...@google.com> wrote:
>
> Is a colon missing on line 4?
>

Nope, I wouldn't have bothered you all with an e-mail without closely
checking my syntax. As it turns out, Allan's suggestion was correct:
one of the third-party packages I was using (Express) was the cause of
the conflict. I changed their logging implementation to comply with
what is suggested here:
http://blog.dartwatch.com/2013/05/campaign-to-use-real-logging-instead-of.html

Now their logging works just fine with my own logging.

Thanks Allan for the suggestion.

Kind regards,

Eric

Peter Ahé

unread,
Dec 7, 2013, 2:17:18 PM12/7/13
to General Dart Discussion
The reason why I suggested a colon is that it looks like a parser
error from the VM. However, I meant semicolon :-)

It still looks like a parser error, so I'd really like to know what
the previous four lines looked like. So I can rule out if this is a
parser bug, or a case where we could produce a better error message.

Cheers,
Peter

Eric Bullington

unread,
Dec 9, 2013, 10:07:37 AM12/9/13
to mi...@dartlang.org
On Sat, Dec 7, 2013 at 2:17 PM, Peter Ahé <a...@google.com> wrote:
> The reason why I suggested a colon is that it looks like a parser
> error from the VM. However, I meant semicolon :-)
>

Sorry for the delay in responding. And I did read your sentence as
semicolon...didn't even notice the discrepancy. But yes, I had one in
place.

It turns out that I was facing two errors with implementing logging,
both rather subtle to a Dart newcomer. See below.

> It still looks like a parser error, so I'd really like to know what
> the previous four lines looked like. So I can rule out if this is a
> parser bug, or a case where we could produce a better error message.

OK, I went back and re-created the test app I was playing around with
to try and figure out what was going wrong. And the previous four
lines were simply:

import altapp;

import 'package:logging/logging.dart';

But the problem was that I was then using the Logger keyword outside
of the main function scope. This restriction is mentioned nowhere in
the logging package documentation (that I could find, at least), but I
read in Chris Buckett's blog post I referenced above that the Logger
class must be initialized inside the main function scope. So that was
one of my two problems.

The other problem I was running into was that the Express library I
was using had implemented its own extensible Logger class that was
conflicting with my attempts at initializing my own. Once I went back
and changed Express's logging to the library logging recommended in
the blog post, it worked fine with my app's logging. I could have
probably also used Express's extensible logging, but I decided I
preferred to use Chris's approach (the beauty of open source!).

By the way, I'm really impressed by both the language *and* by
Dartist's Express framework. There's not a lot of documentation on
most Dart libraries at this point, but once I went and read Express's
source code, it became clear that it could be easily extended to do
everything I was looking for (e.g., authentication middleware). I'll
try to write up my own blog post outlining what I've done to help
future Dart users implement server-side apps.

My 2-day impression of Dart is that it's a solid and easy-to-use yet
powerful and safe alternative to JavaScript. My only hesitation in
recommending Dart at the present time would be the relative immaturity
of and the lack of documentation to important third-party libraries
(Dart itself is remarkably well-documented for such a new language).
But I know these things will just take time to develop, and that the
language has only in recent months reached the point of stasis needed
to create solid, dependable third-party packages.

Thank you both for your input.

Eric

Peter Ahé

unread,
Dec 9, 2013, 12:35:14 PM12/9/13
to General Dart Discussion
Thank you. I think we can do better on this error message and I have
filed bugs against the Dart VM and dart2js:

https://code.google.com/p/dart/issues/detail?id=15534
https://code.google.com/p/dart/issues/detail?id=15535

Cheers,
Peter

Günter Zöchbauer

unread,
Dec 9, 2013, 12:58:56 PM12/9/13
to mi...@dartlang.org
I guess this should be

library altapp;
import 'package:logging/logging.dart';


instead of

Eric Bullington

unread,
Dec 9, 2013, 2:45:31 PM12/9/13
to mi...@dartlang.org
You're absolutely right -- I mistranscribed it from my code.  Sorry about that.  The `import` should have been `library`, as you guessed correctly.

And very cool -- thanks to your response I just noticed Google Groups has a syntax highlighting functionality available in the toolbar.
Reply all
Reply to author
Forward
0 new messages