x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

All of my custom Debug logs are not allowing me to compile my code

I add

.h

Declare_Log_Category_Extern(MyLog, Log, All);

.cpp

Define_Log_Category(MyLog);

Once i compile I get these errors:

error C2146: syntax error: missing ';' before identifier 'MyLog'

error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

error C2780: 'void FMsg::Logf_Internal(const ANSICHAR *,int32,const FName &,ELogVerbosity::Type,const FmtType &,Types...)': expects 6 arguments - 4 provided

error C2065: 'CompileTimeVerbosity': undeclared identifier

error C2653: 'FLogCategoryMyLog': is not a class or namespace name

error C2065: 'MyLog': undeclared identifier

error C2672: 'FMsg::Logf_Internal': no matching overloaded function found

error C2146: syntax error: missing ';' before identifier 'MyLog'

I already checked the wiki for Logs and print messages, that didnt help. Where is the proper location to declare and define a custom debug log within a script? Is it within the class? Outside of the class? on top, underneath the includes?

Product Version: UE 4.22
Tags:
more ▼

asked Jul 15 '19 at 09:07 PM in C++ Programming

avatar image

Rosium
8 1 2 5

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

3 answers: sort voted first

Hello,

https://wiki.unrealengine.com/Logs,_Printing_Messages_To_Yourself_During_Runtime#Setting_Up_Your_Own_Log_Category

I'm pretty sure there is log category in a cpp.

DECLARE_LOG_CATEGORY_EXTERN(CategoryName, DefaultVerbosity, CompileTimeVerbosity);

So you should invert your declaration. From CPP to H and from H to CPP.

more ▼

answered Jul 15 '19 at 09:16 PM

avatar image

Przemek2222
426 4 10 14

avatar image Rosium Jul 15 '19 at 09:29 PM

@Przemek2222 I tried that instead of 15 errors i get 2 sets of the same error

error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

error C2146: syntax error: missing ';' before identifier 'MyLog'

avatar image Przemek2222 Jul 17 '19 at 10:17 PM

Macros are written all with big letters so make sure you have DECLARE_LOG_CATEGORY_EXTERN not Declare_Log_Category_Extern ..

avatar image Rosium Jul 29 '19 at 06:47 PM

I understand, However, i still received the same errors, all caps or not :(

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

In C++, capitalisation matters. Your post suggests you've used

 Declare_Log_Category_Extern(MyLog, Log, All);

Instead of

 DECLARE_LOG_CATEGORY_EXTERN(MyLog, Log, All);

And

 Define_Log_Category(MyLog);

Instead of

 DEFINE_LOG_CATEGORY(MyLog);

Update to use capitals and see if that fixes the issue.

Also, My DEFINE_LOG_CATEGORY are in .cpp and DECLATE_LOG_CATEGORY_EXTERN is in .h

more ▼

answered Jul 16 '19 at 03:35 PM

avatar image

phil_me_up
1.6k 6 6 12

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

This is what works for me. Hopefully it will help you as well.

In your project header file (MyProject.h), add the following:

 DECLARE_LOG_CATEGORY_EXTERN(LogMyGame, Warning, All);

In your project cpp file (MyProject.cpp), add the following:

 DEFINE_LOG_CATEGORY(LogMyGame);

Hope this helps.

more ▼

answered Jul 29 '19 at 09:55 PM

avatar image

TimCarter
10 2 2

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question