pw_log: Update macros

- Unconditionally set the PW_LOG_LEVEL_BITS macro since it is not
  configurable.
- Only reserve 2 bits for flags by default. This will align with
  pw_log_tokenized's default configuration.
- Merge redundant PW_LOG_LEVEL_BITS and PW_LOG_LEVEL_BITWIDTH macros.
- Remove deprecated PW_LOG_USE_ULTRA_SHORT_NAMES macro.

Change-Id: Iff19d4e3eefd2ef2ad88107f7bb5d7fba4a1f5aa
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/47860
Commit-Queue: Wyatt Hepler <hepler@google.com>
Reviewed-by: Prashanth Swaminathan <prashanthsw@google.com>
diff --git a/pw_log/docs.rst b/pw_log/docs.rst
index 159d9b6..8924fe1 100644
--- a/pw_log/docs.rst
+++ b/pw_log/docs.rst
@@ -101,6 +101,8 @@
   *flags* - Arbitrary flags the backend can leverage. The semantics of these
   flags are not defined in the facade, but are instead meant as a general
   mechanism for communication bits of information to the logging backend.
+  ``pw_log`` reserves 2 flag bits by default, but log backends may provide for
+  more or fewer flag bits.
 
   Here are some ideas for what a backend might use flags for:
 
diff --git a/pw_log/public/pw_log/levels.h b/pw_log/public/pw_log/levels.h
index 6886b6b..a70abc3 100644
--- a/pw_log/public/pw_log/levels.h
+++ b/pw_log/public/pw_log/levels.h
@@ -24,6 +24,7 @@
 #define PW_LOG_LEVEL_ERROR    4
 #define PW_LOG_LEVEL_CRITICAL 5
 
+// Number of bits required to represent the log level
+#define PW_LOG_LEVEL_BITS     3
 #define PW_LOG_LEVEL_BITMASK  7  // 0b111
-#define PW_LOG_LEVEL_BITWIDTH 3
 // clang-format on
diff --git a/pw_log/public/pw_log/log.h b/pw_log/public/pw_log/log.h
index 56764e3..d3a4b1d 100644
--- a/pw_log/public/pw_log/log.h
+++ b/pw_log/public/pw_log/log.h
@@ -68,10 +68,6 @@
 #include "pw_log/short.h"
 #endif  // PW_LOG_USE_SHORT_NAMES
 
-#if defined(PW_LOG_USE_ULTRA_SHORT_NAMES) && PW_LOG_USE_ULTRA_SHORT_NAMES == 1
-#include "pw_log/shorter.h"
-#endif  // PW_LOG_USE_ULTRA_SHORT_NAMES
-
 #ifndef PW_LOG
 #define PW_LOG(level, flags, message, ...)               \
   do {                                                   \
@@ -109,20 +105,11 @@
   PW_LOG(PW_LOG_LEVEL_CRITICAL, PW_LOG_DEFAULT_FLAGS, message, __VA_ARGS__)
 #endif  // PW_LOG_CRITICAL
 
-// Default: Number of bits available for the log level
-//
-// All log statements have a level, and this define is the number of bits
-// available for the level. Some backends restrict this for better efficiency.
-// By default, pick a restricted but large enough value to work for most cases.
-#ifndef PW_LOG_LEVEL_BITS
-#define PW_LOG_LEVEL_BITS 6
-#endif  // PW_LOG_LEVEL_BITS
-
 // Default: Number of bits available for the log flags
 //
 // All log statements have a flags field, and this define is the number of bits
 // available for the flags. Some backends restrict this for better efficiency.
 // By default, pick a restricted but large enough value to work for most cases.
 #ifndef PW_LOG_FLAG_BITS
-#define PW_LOG_FLAG_BITS 10
+#define PW_LOG_FLAG_BITS 2
 #endif  // PW_LOG_FLAG_BITS
diff --git a/pw_log_multisink/log_queue.cc b/pw_log_multisink/log_queue.cc
index f5b3436..0547449 100644
--- a/pw_log_multisink/log_queue.cc
+++ b/pw_log_multisink/log_queue.cc
@@ -41,9 +41,8 @@
   Status status;
 
   encoder.WriteMessageTokenized(message);
-  encoder.WriteLineLevel(
-      (level & PW_LOG_LEVEL_BITMASK) |
-      ((line << PW_LOG_LEVEL_BITWIDTH) & ~PW_LOG_LEVEL_BITMASK));
+  encoder.WriteLineLevel((level & PW_LOG_LEVEL_BITMASK) |
+                         ((line << PW_LOG_LEVEL_BITS) & ~PW_LOG_LEVEL_BITMASK));
   encoder.WriteFlags(flags);
   encoder.WriteThreadTokenized(thread);
 
diff --git a/pw_log_multisink/log_queue_test.cc b/pw_log_multisink/log_queue_test.cc
index 05bc62a..3d77148 100644
--- a/pw_log_multisink/log_queue_test.cc
+++ b/pw_log_multisink/log_queue_test.cc
@@ -60,7 +60,7 @@
   EXPECT_TRUE(entry_decoder.ReadUint32(&line_level).ok());
   EXPECT_EQ(expected_level, line_level & PW_LOG_LEVEL_BITMASK);
   EXPECT_EQ(expected_line,
-            (line_level & ~PW_LOG_LEVEL_BITMASK) >> PW_LOG_LEVEL_BITWIDTH);
+            (line_level & ~PW_LOG_LEVEL_BITMASK) >> PW_LOG_LEVEL_BITS);
 
   uint32_t flags;
   EXPECT_TRUE(entry_decoder.Next().ok());  // flags
diff --git a/pw_log_sink/log_sink.cc b/pw_log_sink/log_sink.cc
index 4d841e8..b3ef96b 100644
--- a/pw_log_sink/log_sink.cc
+++ b/pw_log_sink/log_sink.cc
@@ -66,7 +66,7 @@
 
   encoder.WriteLineLevel(
       (level & PW_LOG_LEVEL_BITMASK) |
-      ((line_number << PW_LOG_LEVEL_BITWIDTH) & ~PW_LOG_LEVEL_BITMASK));
+      ((line_number << PW_LOG_LEVEL_BITS) & ~PW_LOG_LEVEL_BITMASK));
   encoder.WriteFlags(flags);
 
   // TODO(pwbug/301): Insert reasonable values for thread and timestamp.
diff --git a/pw_log_tokenized/public_overrides/pw_log_backend/log_backend.h b/pw_log_tokenized/public_overrides/pw_log_backend/log_backend.h
index 7b1cac1..57dedea 100644
--- a/pw_log_tokenized/public_overrides/pw_log_backend/log_backend.h
+++ b/pw_log_tokenized/public_overrides/pw_log_backend/log_backend.h
@@ -21,5 +21,4 @@
 
 #define PW_HANDLE_LOG PW_LOG_TOKENIZED_TO_GLOBAL_HANDLER_WITH_PAYLOAD
 
-#define PW_LOG_LEVEL_BITS PW_LOG_TOKENIZED_LEVEL_BITS
 #define PW_LOG_FLAG_BITS PW_LOG_TOKENIZED_FLAG_BITS