Commit Graph

124 Commits

Author SHA1 Message Date
Vincent-Michael
ab90f74486 Update copyright note for 2015
Happy new year
2015-01-01 00:28:09 +01:00
Shauren
b781a4dc33 Core/Logging: Replaced direct calls to GetCounter() in logs with ToString() 2014-10-08 17:59:27 +02:00
DDuarte
a394205eca Core/Server: Add missing overrides 2014-08-09 20:17:40 +01:00
Vincent-Michael
946ab3e8b7 Core: Kill again whitespace :( 2014-07-21 18:14:22 +02:00
Vincent-Michael
0531f52008 Core: Fix non pch build (gcc) 2014-07-20 02:54:12 +02:00
leak
dce92611f3 Refactored singletons to enable proper deconstruction during shutdown 2014-07-20 00:40:08 +02:00
leak
d1594998f8 Replaced the LogWorker thread with Boost ASIO 2014-07-08 20:55:25 +02:00
leak
029bad6698 Replaced all remaining ACE based Singletons
Replaced ACE base AutoPtr class with shared_ptr
Note: worldserver currently broken due to MapUpdater threading failure (ACE ofc, what else could it be)
2014-07-01 00:54:09 +02:00
leak
eb36acd152 Replaced ACE_Task_Base based LogWorker with ProducerConsumerQueue 2014-06-30 14:44:52 +02:00
leak
d8d0b4730e Revert "Removed ACE dependencies from LogWorker" This actually needs way more work
This reverts commit 0a592dd9db.
2014-06-24 21:10:07 +02:00
leak
0a592dd9db Removed ACE dependencies from LogWorker 2014-06-24 19:13:29 +02:00
Subv
0db743c4ff Merge branch 'master' of github.com:TrinityCore/TrinityCore into boost
Conflicts:
	src/server/authserver/Server/AuthSession.cpp
	src/server/game/Server/WorldSession.h
	src/server/shared/Packets/ByteBuffer.cpp
	src/server/shared/Utilities/Util.h
2014-06-23 16:35:54 -05:00
leak
28b61812cf Fix non-PCH build 2014-06-23 21:02:13 +02:00
Subv
f9a08ac1c9 Core/Dependencies: Remove ACE_Singleton dependency from the Log and DelayExecutor classes.
Removed an unused function.
2014-06-22 14:07:23 -05:00
Subv
79440b3d9d Shared/Misc: Removed some more ACE dependencies 2014-06-22 13:17:47 -05:00
leak
7dd6f0f1d8 Replaced all ACE_OS::localtime_r calls 2014-06-22 15:42:46 +02:00
leak
0dd10269d1 Replaced dependencies on ace/OS_NS_time.h 2014-06-08 20:08:43 +02:00
jackpoz
7228bd3664 Revert "Core/Logging: Use logger cache for speed up logger filter search"
This reverts commit 39331ea7b9.
This is required to fix a race condition introduced with the logger cache. Adding a locking mechanism might make worthless the speed gain added by the cache itself, push a proper thread-safe implementation if it's worth it.

Helgrind log:
Possible data race during write of size 8 at 0x736F428 by thread #1
Locks held: none
   at 0x11872DF: std::_Hashtable<std::string, std::pair<std::string const, Logger const*>, std::allocator<std::pair<std::string const, Logger const*> >, std::__detail::_Select1st, std::equal_to<std::string>, std::hash<std::string>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<true, false, true> >::_M_insert_bucket_begin(unsigned long, std::__detail::_Hash_node<std::pair<std::string const, Logger const*>, true>*) (hashtable.h:1196)
   by 0x11865A1: std::_Hashtable<std::string, std::pair<std::string const, Logger const*>, std::allocator<std::pair<std::string const, Logger const*> >, std::__detail::_Select1st, std::equal_to<std::string>, std::hash<std::string>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<true, false, true> >::_M_insert_unique_node(unsigned long, unsigned long, std::__detail::_Hash_node<std::pair<std::string const, Logger const*>, true>*) (hashtable.h:1342)
   by 0x1185A48: std::__detail::_Map_base<std::string, std::pair<std::string const, Logger const*>, std::allocator<std::pair<std::string const, Logger const*> >, std::__detail::_Select1st, std::equal_to<std::string>, std::hash<std::string>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<true, false, true>, true>::operator[](std::string const&) (hashtable_policy.h:496)
   by 0x1184F3A: std::unordered_map<std::string, Logger const*, std::hash<std::string>, std::equal_to<std::string>, std::allocator<std::pair<std::string const, Logger const*> > >::operator[](std::string const&) (unordered_map.h:596)
   by 0x1184495: Log::GetLoggerByType(std::string const&) (Log.h:106)
   by 0x1184527: Log::ShouldLog(std::string const&, LogLevel) (Log.h:112)
   by 0x16E7121: World::LoadConfigSettings(bool) (World.cpp:909)
   by 0x16EB623: World::SetInitialWorldSettings() (World.cpp:1276)
   by 0x118F0EC: Master::Run() (Master.cpp:169)
   by 0x1196AFF: main (Main.cpp:142)

This conflicts with a previous read of size 8 by thread #3
Locks held: none
   at 0x1186EA6: std::_Hashtable<std::string, std::pair<std::string const, Logger const*>, std::allocator<std::pair<std::string const, Logger const*> >, std::__detail::_Select1st, std::equal_to<std::string>, std::hash<std::string>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<true, false, true> >::_M_find_before_node(unsigned long, std::string const&, unsigned long) const (hashtable.h:1162)
   by 0x1186263: std::_Hashtable<std::string, std::pair<std::string const, Logger const*>, std::allocator<std::pair<std::string const, Logger const*> >, std::__detail::_Select1st, std::equal_to<std::string>, std::hash<std::string>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<true, false, true> >::_M_find_node(unsigned long, std::string const&, unsigned long) const (hashtable.h:604)
   by 0x11857B9: std::_Hashtable<std::string, std::pair<std::string const, Logger const*>, std::allocator<std::pair<std::string const, Logger const*> >, std::__detail::_Select1st, std::equal_to<std::string>, std::hash<std::string>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<true, false, true> >::find(std::string const&) (hashtable.h:1025)
   by 0x1184DE2: std::unordered_map<std::string, Logger const*, std::hash<std::string>, std::equal_to<std::string>, std::allocator<std::pair<std::string const, Logger const*> > >::find(std::string const&) (unordered_map.h:543)
   by 0x11842EF: Log::GetLoggerByType(std::string const&) (Log.h:84)
   by 0x1184527: Log::ShouldLog(std::string const&, LogLevel) (Log.h:112)
   by 0x189AACA: MySQLConnection::Execute(char const*) (MySQLConnection.cpp:175)
   by 0x18A3225: BasicStatementTask::Execute() (AdhocStatement.cpp:56)

Address 0x736F428 is 120 bytes inside a block of size 184 alloc'd
   at 0x4C2AE3A: operator new(unsigned long, std::nothrow_t const&) (vg_replace_malloc.c:350)
   by 0x1185046: ACE_Singleton<Log, ACE_Thread_Mutex>::instance() (Singleton.cpp:91)
   by 0x11968E2: main (Main.cpp:135)
2014-05-18 16:53:29 +02:00
jackpoz
0904858624 Revert "Core/Logging: store loggers in cache correctly"
This reverts commit c6a4d5a1de.
2014-05-18 16:04:59 +02:00
Dehravor
cbd36d5a4e Core/Misc: Remove remaining COMPILER_HAS_CPP11_SUPPORT related macros 2014-05-01 11:19:32 +02:00
joschiwald
c6a4d5a1de Core/Logging: store loggers in cache correctly 2014-04-08 21:27:02 +02:00
Shauren
aeff7944d1 Core/Logging: Fixed filenames of backup logs
Closes #11765
2014-03-24 09:01:44 +01:00
Shauren
e469ff5e88 Fixed build without PCH 2014-03-23 12:54:09 +01:00
jackpoz
592b57a251 Shared/Logs: Code cleanup
Remove unneeded check added in 89af6097f3
2014-02-08 11:35:25 +01:00
jackpoz
89af6097f3 Shared/Logs: Make AppenderFile more thread-safe
In case of dynamic file names don't store the FILE* handle in a shared class variable but keep it only at function scope.

Valgrind log:
  at _IO_un_link (genops.c:69)
  by fclose@@GLIBC_2.2.5 (iofclose.c:55)
  by AppenderFile::CloseFile() (AppenderFile.cpp:94)
  by AppenderFile::_write(LogMessage const&) (AppenderFile.cpp:66)
  by Appender::write(LogMessage&) (Appender.cpp:102)
  by Logger::write(LogMessage&) const (Logger.cpp:63)
  by Log::write(LogMessage*) (Log.cpp:279)
  by Log::vlog(std::string const&, LogLevel, char const*, __va_list_tag*) (Log.cpp:267)
  by Log::outMessage(std::string const&, LogLevel, char const*, ...) (Log.h:129)
Address 0x2a1bd2d0 is 0 bytes inside a block of size 568 free'd
  at free (vg_replace_malloc.c:468)
  by fclose@@GLIBC_2.2.5 (iofclose.c:85)
  by AppenderFile::CloseFile() (AppenderFile.cpp:94)
  by AppenderFile::_write(LogMessage const&) (AppenderFile.cpp:66)
  by Appender::write(LogMessage&) (Appender.cpp:102)
  by Logger::write(LogMessage&) const (Logger.cpp:63)
  by Log::write(LogMessage*) (Log.cpp:279)
  by Log::vlog(std::string const&, LogLevel, char const*, __va_list_tag*) (Log.cpp:267)
  by Log::outMessage(std::string const&, LogLevel, char const*, ...) (Log.h:129)
2014-02-07 23:35:03 +01:00
jackpoz
672e06a951 Shared/Logs: Add workaround for "w" flag used with dynamic name files
Ignore "w" flag and always use "a" for log files with dynamic name since the file handle is created at every log line and "w" would delete any other logged line from previous _write() calls.
The best solution would be to overwrite only at first call and append at any other call.
2014-02-07 22:23:24 +01:00
Vincent_Michael
20004050bc Update copyright note for 2014.
Happy new year.
2014-01-01 00:07:53 +01:00
Spp
39331ea7b9 Core/Logging: Use logger cache for speed up logger filter search 2013-12-19 10:34:55 +01:00
Spp
cd48662233 Core/Logging: Minor changes
- Select stderr when writing ERROR and FATAL messages
- Simplify function defines
- Fix `logs` table structure with latest logging changes
2013-11-11 14:35:16 +01:00
Spp
94e2b9332a Core/Logging: Remove LOG_FILTER_XXX defines with it's value (remember logger names are case-sensitive) 2013-11-08 10:50:51 +01:00
Spp
1b04bec290 Core/Logs: Create default set of loggers and Appender if the config is wrong.
- Logger root (Error)
- Logger server (Info)
- Appender Console

Logger names are case-sensitive, Appender names are not.
2013-11-08 08:55:10 +01:00
Spp
8aa9745c4c Core/Logging: Extend logging system to allow inheritance of loggers
- Changed default loggers and appenders
- '.' determines the relation between loggers ("type.subtype" inherits "type" logger setting if logger "type.subtype" is not defined)
- When core logs a message it search for the correct logger (root is the default one)
  ie: a message logged with "type.subtype"
  * Core will try to find a logger with name "type.subtype", if its not found then will search for "type", again if its not found it will return the default one "root"
2013-11-07 16:34:44 +01:00
leguybrush
0a308144a8 Core/Code: Unify [more] codestyle for brackets: )\n{\n} to ) { }. 2013-10-28 14:36:07 -04:00
jackpoz
1b3575ba77 Core/Logs: Fix race condition in Log
Fix race condition in Log by using atomic operators.

Helgrind log:
 Possible data race during read of size 8 at 0x7379D98 by thread #1
 Locks held: none
  at 0x15AE9C7: AppenderFile::_write(LogMessage const&) (AppenderFile.cpp:59)
  by 0x15ADFF8: Appender::write(LogMessage&) (Appender.cpp:106)
  by 0x159F14E: Logger::write(LogMessage&) (Logger.cpp:83)
  by 0x15A215B: Log::write(LogMessage*) (Log.cpp:290)
  by 0x15A200F: Log::vlog(LogFilterType, LogLevel, char const*, __va_list_tag*) (Log.cpp:272)
  by 0x15A2682: Log::outInfo(LogFilterType, char const*, ...) (Log.cpp:364)
  by 0xF7DA28: Master::Run() (Master.cpp:296)
  by 0xF835E8: main (Main.cpp:142)

 This conflicts with a previous write of size 8 by thread #10
 Locks held: none
  at 0x15AE9D7: AppenderFile::_write(LogMessage const&) (AppenderFile.cpp:59)
  by 0x15ADFF8: Appender::write(LogMessage&) (Appender.cpp:106)
  by 0x159F14E: Logger::write(LogMessage&) (Logger.cpp:83)
  by 0x15A215B: Log::write(LogMessage*) (Log.cpp:290)
  by 0x15A200F: Log::vlog(LogFilterType, LogLevel, char const*, __va_list_tag*) (Log.cpp:272)
  by 0x15A2682: Log::outInfo(LogFilterType, char const*, ...) (Log.cpp:364)
  by 0xF7EC1F: FreezeDetectorRunnable::run() (Master.cpp:98)
  by 0x15A5B3E: ACE_Based::Thread::ThreadTask(void*) (Threading.cpp:186)

 Address 0x7379D98 is 88 bytes inside a block of size 96 alloc'd
  at 0x4C2C857: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_helgrind-amd64-linux.so)
  by 0x15A0FE3: Log::CreateAppenderFromConfig(char const*) (Log.cpp:150)
  by 0x15A1AED: Log::ReadAppendersFromConfig() (Log.cpp:244)
  by 0x15A31B4: Log::LoadFromConfig() (Log.cpp:469)
  by 0x15A053B: Log::Log() (Log.cpp:35)
  by 0xF75CD1: ACE_Singleton<Log, ACE_Thread_Mutex>::ACE_Singleton() (Singleton.inl:13)
  by 0xF754A4: ACE_Singleton<Log, ACE_Thread_Mutex>::instance() (Singleton.cpp:91)
  by 0xF8351A: main (Main.cpp:135)
2013-09-13 19:59:50 +02:00
jackpoz
9578b5f87a Core/Thread: Fix race condition converting time values to local time
Replace thread-unsafe localtime() http://www.cplusplus.com/reference/ctime/localtime/ with thread-safe portable ACE_OS::localtime_r() .

Helgrind log:
 Possible data race during read of size 4 at 0x6F183C0 by thread #1
 Locks held: none
  at 0x14E72E3: World::InitDailyQuestResetTime() (World.cpp:2772)
  by 0x14E3A01: World::SetInitialWorldSettings() (World.cpp:1790)
  by 0x101122A: Master::Run() (Master.cpp:164)
  by 0x101740C: main (Main.cpp:142)

 This conflicts with a previous write of size 4 by thread #2
 Locks held: none
  at 0x6C2D3BA: __tzfile_compute (tzfile.c:797)
  by 0x6C2D036: __tz_convert (tzset.c:627)
  by 0x164146C: LogMessage::getTimeStr(long) (Appender.cpp:23)
  by 0x1641550: LogMessage::getTimeStr() (Appender.cpp:31)
  by 0x1641722: Appender::write(LogMessage&) (Appender.cpp:80)
  by 0x1633FCE: Logger::write(LogMessage&) (Logger.cpp:83)
  by 0x16433D8: LogOperation::call() (LogOperation.cpp:29)
  by 0x16428A4: LogWorker::svc() (LogWorker.cpp:45)
2013-09-07 14:37:54 +02:00
Shauren
779a59e7e2 Core/Config: Refactored ConfigMgr
* Loading initial configuration files is now separate from loading any additional custom configs
2013-07-15 17:31:44 +02:00
Shauren
86d846e627 Core: Fixed windows compile 2013-05-13 18:10:20 +02:00
Spp
d1677b2db0 Core/Logging: Performance-related tweaks to logging system
All sLog->out* functions (except outCommand atm) are replaced with TC_LOG_* macros.
    Memleak fix
2013-05-13 15:07:36 +02:00
Spp
1a6a23ec96 Core/Misc: Minor optimizations (+code changes to reduce differences with 4.3.4 branch)
Core/Logging: Create new logger type "Cheat". Will be used to log all cheat attempts
2013-03-25 13:26:48 +01:00
Spp
480c6cf4dd Core/RBAC: Add .reload rbac command and prevent possible crash if rbac_permissions has wrong data 2013-02-27 03:30:53 +01:00
Spp
fd882a4e61 Core/Logging: Fix mem leak. Thanks to @Sar777 for the report 2013-02-21 01:10:58 +01:00
click
75994b3dd3 Core: Clean up whitespace, and remove a silly warning in boss_lurker_below.cpp 2013-02-07 00:19:19 +01:00
Spp
fa5dd4bd4e Core/Misc: Remove some calls to const_cast 2013-01-30 08:39:06 +01:00
Machiavelli
61495d18a3 Core/Log: Fix crash due to uninitialized variable 2013-01-25 21:40:21 +01:00
Spp
0d3cc3ae3a Core/Log: Fix console colors (missing change from 53a3373)
Closes #9051
2013-01-24 21:52:29 +01:00
Spp
53a3373a98 Core/Logging: Fix all possible crashes when using bad Appender config settings 2013-01-24 16:57:35 +01:00
springfieldking
389a4899f4 Update src/server/shared/Logging/Log.cpp
Fix crash when the last iter plus and change value
2013-01-24 22:26:11 +08:00
Spp
23b6a6a7cd Core/Log: Rotate logs when maximum size is exceeded, backup name will be "filename".datetime
- This is an addition to 39c2d89
2013-01-24 12:44:58 +01:00
Machiavelli
39c2d892f3 Core/Log: Allow configuring a maximum file size for a log file. If the file size is about to be exceeded, the core will create a new file titled <oldname>_.log and start outputting there. 2013-01-23 17:48:17 +01:00
Spp
526bdc0764 Core/Logging: Add config option to enable/disable asyncronous logging (disabled by default) 2013-01-16 09:52:49 +01:00