Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
1.3 KiB

  1. @REM -----------------------------------------------------------------
  2. @REM
  3. @REM errmsg.cmd - JeremyD
  4. @REM Logs error messages to the screen and in a log file
  5. @REM
  6. @REM Copyright (c) Microsoft Corporation. All rights reserved.
  7. @REM
  8. @REM -----------------------------------------------------------------
  9. @perl -x "%~f0" %*
  10. @set /a errors=errors+1
  11. @goto :EOF
  12. #!perl
  13. use strict;
  14. use lib $ENV{RAZZLETOOLPATH};
  15. use ParseArgs;
  16. use Logmsg;
  17. sub Usage { print<<USAGE; exit(1) }
  18. Prints the given string to the screen and into a file. Used by command
  19. scripts to log messages.
  20. usage: errmsg.cmd <message> [logfile]
  21. message Specifies the text to be logged, should be quoted
  22. logfile Specifies the name of the log file. LOGFILE, if
  23. defined, is the default. If this parameter is not
  24. specified and LOGFILE is not defined, the message is
  25. displayed on the screen only.
  26. The output message has the format:
  27. [yyyy/mm/dd-hh:mm:ss] (%SCRIPT_NAME%) : message
  28. Example:
  29. call errmsg.cmd "This is the message to display."
  30. USAGE
  31. my ($message, $logfile, $foo);
  32. parseargs('?' => \&Usage,
  33. \$message,
  34. \$logfile);
  35. if ($logfile) {
  36. $ENV{LOGFILE} = $logfile;
  37. }
  38. $ENV{SCRIPT_NAME} ||= '????';
  39. errmsg($message);