winglian commited on
Commit
245c5c4
1 Parent(s): a546ca2

log rank too (#527)

Browse files
Files changed (1) hide show
  1. src/axolotl/logging_config.py +2 -1
src/axolotl/logging_config.py CHANGED
@@ -23,6 +23,7 @@ class ColorfulFormatter(Formatter):
23
  }
24
 
25
  def format(self, record):
 
26
  log_message = super().format(record)
27
  return self.COLORS.get(record.levelname, "") + log_message + Fore.RESET
28
 
@@ -35,7 +36,7 @@ DEFAULT_LOGGING_CONFIG: Dict[str, Any] = {
35
  },
36
  "colorful": {
37
  "()": ColorfulFormatter,
38
- "format": "[%(asctime)s] [%(levelname)s] [%(name)s.%(funcName)s:%(lineno)d] [PID:%(process)d] %(message)s",
39
  },
40
  },
41
  "filters": {},
 
23
  }
24
 
25
  def format(self, record):
26
+ record.rank = int(os.getenv("LOCAL_RANK", "0"))
27
  log_message = super().format(record)
28
  return self.COLORS.get(record.levelname, "") + log_message + Fore.RESET
29
 
 
36
  },
37
  "colorful": {
38
  "()": ColorfulFormatter,
39
+ "format": "[%(asctime)s] [%(levelname)s] [%(name)s.%(funcName)s:%(lineno)d] [PID:%(process)d] [RANK:%(rank)d] %(message)s",
40
  },
41
  },
42
  "filters": {},