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

Support for Log4Perl #1412

Closed
giddel opened this issue Jan 13, 2017 · 10 comments
Closed

Support for Log4Perl #1412

giddel opened this issue Jan 13, 2017 · 10 comments

Comments

@giddel
Copy link

giddel commented Jan 13, 2017

First: Geat thanks for this wonderful plugin. It's reallly the best perl-pluging of all IDEs I've ever seen.

I'm heavily use the Log::Log4perl logging framework in my projects. But the methods are not proper supported by Camelcade.

1 package MyPackage;
2  
3 use Log::Log4perl qw(get_logger); 
4 
5 sub myMethod {
6    my Log::Log4perl::Logger $logger = get_logger();
7 
8    $logger->debug("foo");
9 }

1)The type of the returned object (Log::Log4perl::Logger) from the exported function get_logger() ist not regognized. I have to prefix ist manually (like line 6)
2) The exported sub "get_logger" ist marked by:
"Unable to find sub definition, declaration, constant definition or typeglob aliasing less... (Strg+F1) "
in line 6
3) If I type $logger->.. (line 8) a lot of methods are suggested, but not the most used logging-methods: debug, info, warn, fatal.
4) The debug() - method itself is also remarked with the "Unable to find sub definition..."

Is it possible to fix it?

Here is a screenshot:
log4perl

@hurricup hurricup added this to the 2018.1 milestone Nov 27, 2017
@hurricup hurricup modified the milestones: 2017.5, 2018.2 Feb 27, 2018
@hurricup hurricup removed this from the 2018.1 milestone Mar 27, 2018
@hurricup hurricup added Feature and removed Bug labels May 31, 2018
@hurricup
Copy link
Collaborator

There are no plain definitions of methods you've specified. They are all introduced using perl magick. Such kind of magick i s not yet supported.

@giddel
Copy link
Author

giddel commented Jun 1, 2018

I feared something like that.
Thanks anyway!

@giddel giddel closed this as completed Jun 1, 2018
@hurricup
Copy link
Collaborator

hurricup commented Jun 1, 2018

Nono, don't close. may be sometime.

@hurricup hurricup reopened this Jun 1, 2018
@hurricup hurricup added this to the 2019.1 milestone Feb 23, 2019
@giddel
Copy link
Author

giddel commented Feb 25, 2019

Wow, great. Thank you! I didn't believe for a solution after 2 years.
Unfortunately I'm not using Perl any more...
But hopefully someone else will enjoy on this now.
Good Job!

@exic
Copy link

exic commented Jan 17, 2020

Hey, I'm trying to use it now, but I still get

Unable to find sub definition, declaration, constant definition or typeglob aliasing 
 Inspection info: Check if sub has been defined, declared or aliased with a typeglob. More information available in our wiki.

on all my log statements.

use Log::Log4perl qw(:easy);
Log::Log4perl->easy_init({ level => $DEBUG, layout => "%d %-5p %m%n" });
my $logger = Log::Log4perl->get_logger('blah');
$logger->info("...");

am I doing something wrong? I'm using version 2019.3.

@hurricup
Copy link
Collaborator

Works fine to me.

image

Do you have Log::Log4perl installed in selected perl? What is perl version and module version?

@exic
Copy link

exic commented Jan 19, 2020

Hey, thanks for checking :-) I have those:

perl -v
This is perl 5, version 28, subversion 1 (v5.28.1) built for x86_64-linux-gnu-thread-multi
[...]
perl -MLog::Log4perl -le 'print $Log::Log4perl::VERSION'
1.49
perl test.pl                            
2020/01/19 13:20:52 INFO  ...

So Log4perl seems to be installed for this Perl (right?). In the settings, I just switched my Target Version to 5.28, too, but that didn't change anything:

2020-01-19-132453_803x194_scrot

Looking at your screenshot, it seems like your info is marked, too, isn't that the same warning as I am seeing?

If that's of relevance, I'm using PyCharm 2019.3.1.

@hurricup
Copy link
Collaborator

@exic
Copy link

exic commented Jan 24, 2020

Okay, I read both pages before but wasn't really able to see where Log4perl fits in there. Is it that it is a $other_obj->method(); # we know that it's a Foo::Baz method like in the example, but can't be found because it is not set up explicitly enough inside the Log4perl package (indeed, I didn't find a sub info in the module..)? I expected it to be fixed because of point 4) in the original issue. Looks like you were able to fix 2) which was similar, right?

Is there anything I can do except disabling the inspection altogether?

@hurricup
Copy link
Collaborator

Can't check myself atm, but its one of:

  1. We can't understand what class object is $logger (for this you may hint with annotation or exlicit typing)
  2. There is no explicit definition or declaration of info method in that class. and this requires additional efforts on plugin side (or you may make a file with fake declarations, but this may be a bad way)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants