analogger 1.28.3 → 1.29.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1882,20 +1882,25 @@ class ____AnaLogger
1882
1882
  * If the context contain a key onLogging that is a function,
1883
1883
  * execute
1884
1884
  * @param context
1885
+ * @param data
1885
1886
  * @param extras
1887
+ * @param callbackName
1886
1888
  * @returns {*}
1887
1889
  */
1888
- checkOnLogging(context, extras)
1890
+ checkOnLogging(context, data, extras, callbackName )
1889
1891
  {
1892
+ if (!callbackName) {
1893
+ return ;
1894
+ }
1890
1895
  try
1891
1896
  {
1892
- let callback = context.onLogging;
1897
+ let callback = context[callbackName];
1893
1898
  if (typeof callback !== "function")
1894
1899
  {
1895
1900
  return;
1896
1901
  }
1897
1902
 
1898
- return callback.call(this, context, extras);
1903
+ return callback.call(this, data, extras);
1899
1904
  }
1900
1905
  catch (e)
1901
1906
  {
@@ -1913,6 +1918,7 @@ class ____AnaLogger
1913
1918
  let message = "";
1914
1919
  this.applySymbolByName(context);
1915
1920
 
1921
+ this.checkOnLogging(context, context, arguments, "onContext");
1916
1922
  if (!this.isTargetAllowed(context.target))
1917
1923
  {
1918
1924
  return;
@@ -1929,6 +1935,10 @@ class ____AnaLogger
1929
1935
  }
1930
1936
 
1931
1937
  // Clone arguments without the context (= the first argument passed) to generate the message
1938
+ const newMessages = this.checkOnLogging(context, arguments && arguments.length > 1? arguments[1] : arguments, arguments,"onMessage");
1939
+ if (newMessages !== undefined) {
1940
+ arguments[1] = newMessages;
1941
+ }
1932
1942
  let args = Array.prototype.slice.call(arguments, 1 /* => Ignore arguments[0] = context */);
1933
1943
 
1934
1944
  message = this.convertArgumentsToText(args);
@@ -1943,14 +1953,16 @@ class ____AnaLogger
1943
1953
 
1944
1954
  ++this.logCounter;
1945
1955
 
1946
- let proceedFurther;
1947
-
1948
- proceedFurther = this.checkOnLogging(context, {message, text, args, logCounter: this.logCounter});
1956
+ let proceedFurther = this.checkOnLogging(context, text, {message, args, logCounter: this.logCounter}, "onOutput");
1949
1957
  // If one of the plugins returns false, no further operation will follow
1950
1958
  if (proceedFurther === false)
1951
1959
  {
1952
1960
  return;
1953
1961
  }
1962
+ else if (typeof proceedFurther === 'string' || proceedFurther instanceof String)
1963
+ {
1964
+ text = proceedFurther;
1965
+ }
1954
1966
 
1955
1967
  proceedFurther = this.checkPlugins(context, {message, text, args, logCounter: this.logCounter});
1956
1968
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "analogger",
3
- "version": "1.28.3",
3
+ "version": "1.29.2",
4
4
  "description": "Js Logger",
5
5
  "main": "./src/ana-logger.cjs",
6
6
  "module": "./esm/src/ana-logger.mjs",
@@ -1870,20 +1870,25 @@ class ____AnaLogger
1870
1870
  * If the context contain a key onLogging that is a function,
1871
1871
  * execute
1872
1872
  * @param context
1873
+ * @param data
1873
1874
  * @param extras
1875
+ * @param callbackName
1874
1876
  * @returns {*}
1875
1877
  */
1876
- checkOnLogging(context, extras)
1878
+ checkOnLogging(context, data, extras, callbackName )
1877
1879
  {
1880
+ if (!callbackName) {
1881
+ return ;
1882
+ }
1878
1883
  try
1879
1884
  {
1880
- let callback = context.onLogging;
1885
+ let callback = context[callbackName];
1881
1886
  if (typeof callback !== "function")
1882
1887
  {
1883
1888
  return;
1884
1889
  }
1885
1890
 
1886
- return callback.call(this, context, extras);
1891
+ return callback.call(this, data, extras);
1887
1892
  }
1888
1893
  catch (e)
1889
1894
  {
@@ -1901,6 +1906,7 @@ class ____AnaLogger
1901
1906
  let message = "";
1902
1907
  this.applySymbolByName(context);
1903
1908
 
1909
+ this.checkOnLogging(context, context, arguments, "onContext");
1904
1910
  if (!this.isTargetAllowed(context.target))
1905
1911
  {
1906
1912
  return;
@@ -1917,6 +1923,10 @@ class ____AnaLogger
1917
1923
  }
1918
1924
 
1919
1925
  // Clone arguments without the context (= the first argument passed) to generate the message
1926
+ const newMessages = this.checkOnLogging(context, arguments && arguments.length > 1? arguments[1] : arguments, arguments,"onMessage");
1927
+ if (newMessages !== undefined) {
1928
+ arguments[1] = newMessages;
1929
+ }
1920
1930
  let args = Array.prototype.slice.call(arguments, 1 /* => Ignore arguments[0] = context */);
1921
1931
 
1922
1932
  message = this.convertArgumentsToText(args);
@@ -1931,14 +1941,16 @@ class ____AnaLogger
1931
1941
 
1932
1942
  ++this.logCounter;
1933
1943
 
1934
- let proceedFurther;
1935
-
1936
- proceedFurther = this.checkOnLogging(context, {message, text, args, logCounter: this.logCounter});
1944
+ let proceedFurther = this.checkOnLogging(context, text, {message, args, logCounter: this.logCounter}, "onOutput");
1937
1945
  // If one of the plugins returns false, no further operation will follow
1938
1946
  if (proceedFurther === false)
1939
1947
  {
1940
1948
  return;
1941
1949
  }
1950
+ else if (typeof proceedFurther === 'string' || proceedFurther instanceof String)
1951
+ {
1952
+ text = proceedFurther;
1953
+ }
1942
1954
 
1943
1955
  proceedFurther = this.checkPlugins(context, {message, text, args, logCounter: this.logCounter});
1944
1956