Right way to perform Log transformation without data leakage i am transforming my data like this
import numpy as np
X_train = np.log(X_train)
X_test = np.log(X_test)

but someone told me that this wrong way to do that, you should save the mean of train set & then perform it on test_set.
I tried this but my result is same as if directly Log-tranform my dataset
from sklearn.preprocessing import FunctionTransformer
transformer = FunctionTransformer(np.log1p)
transformer.fit(train_x)

train_x_scaled = transformer.fit_transform(train_x)
test_x_scaled = transformer.fit_transform(test_x)

What is the correct way to do this task?
My dataset is skewed on 1 side. Therefore i am performing Log-Transformation. 
 A: If it were standardisation or normalisation or any other type of transformation that actually learns some parameters from the data and applies it to the next/incoming data, you'd have to first split into train/test, fit your transformation with training set and apply it to the test set, so that you don't learn parameters from the test set.
However, yours (i.e. np.log1p) is a simple transformation that doesn't use any learnable parameters, and it won't matter if you do it before or after the split. It's like dividing a feature by 1000. But, as a rule of thumb, it's better to keep the ordering as it is for parametric transformations (e.g. standardisation) so that when you modify your code and add additional transformations, you won't end up in a bug.
Pipeline in sklearn enables you to set up trainable blocks that contain both your models and transformations in order, so that when fitted, it only uses training data.
A: The issue is that you are calling fit_transform on both the training data and the test data.  In other words, you are retraining the transformer on both the training and the test data, whereas to prevent data leakage (which is quite minor in this case, but in general is important to avoid) you would only want to fit the transformer on the train data. In this case you would call fit_transform on the training data, but only transform on the test data.  Also, since you independently fit the transformer, you can simply call transform (not fit_transform) on the training data. You can change the last 2 lines:
train_x_scaled = transformer.transform(train_x)
test_x_scaled = transformer.transform(test_x)

