Improved logging function with the use of LogSource and different log levels